mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Follow up #3223 - modify test, could use @Column(insertable = false, updatable = false) instead of @Formula
This commit is contained in:
@@ -3,10 +3,7 @@ package org.tests.model.composite;
|
||||
|
||||
import io.ebean.annotation.Formula;
|
||||
import io.ebean.annotation.Index;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
@Entity
|
||||
public class DataWithFormula {
|
||||
@@ -14,9 +11,11 @@ public class DataWithFormula {
|
||||
@EmbeddedId
|
||||
private DataWithFormulaKey id;
|
||||
|
||||
// @Column(insertable = false, updatable = false)
|
||||
@Formula(select = "${ta}.meta_key")
|
||||
private String metaKey;
|
||||
|
||||
// @Column(insertable = false, updatable = false)
|
||||
@Formula(select = "${ta}.value_index")
|
||||
private Integer valueIndex;
|
||||
|
||||
|
||||
@@ -35,5 +35,13 @@ class TestDataWithFormula extends BaseTestCase {
|
||||
assertThat(sqls.get(1)).contains("insert into data_with_formula (main_id, meta_key, value_index, string_value) values (?,?,?,?)"); // main
|
||||
assertThat(sqls.get(2)).contains("-- bind");
|
||||
|
||||
|
||||
DataWithFormula found = DB.find(DataWithFormula.class)
|
||||
.where().idEq(key)
|
||||
.findOne();
|
||||
|
||||
assertThat(found.getStringValue()).isEqualTo("SomeValue");
|
||||
assertThat(found.getId().getMainId()).isEqualTo(key.getMainId());
|
||||
assertThat(found.getMetaKey()).isEqualTo(key.getMetaKey());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user