mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1920 Support @Index concurrently and definition
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.Platform;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
@@ -13,7 +14,8 @@ import javax.validation.constraints.Size;
|
||||
/**
|
||||
* A basic entity to test simple things.
|
||||
*/
|
||||
//@Index(name = "t_detail_foo_name", unique = true, columnNames = "lower(name)")
|
||||
@Index(name = "ix_t_detail_with_other_namexxxyy_lowername", unique = true, columnNames = "lower(name)", concurrent = true, platforms = Platform.POSTGRES)
|
||||
@Index(name = "ix_t_detail_with_other_namexxxyy_defn", platforms = Platform.POSTGRES, definition = "create index ix_t_detail_with_other_namexxxyy_defn on t_detail_with_other_namexxxyy using hash (lower(name)) where lower(name) like 'r%'")
|
||||
@Entity
|
||||
@Table(name = "t_detail_with_other_namexxxyy")
|
||||
public class TSDetail {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package org.tests.saveassociation;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.DB;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.TSDetail;
|
||||
import org.tests.model.basic.TSMaster;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class TestSaveSamePK extends BaseTestCase {
|
||||
|
||||
@@ -13,22 +14,22 @@ public class TestSaveSamePK extends BaseTestCase {
|
||||
public void test() {
|
||||
|
||||
// delete in case we are running multiple times without full db drop
|
||||
Ebean.delete(TSMaster.class, 10000);
|
||||
DB.delete(TSMaster.class, 10000);
|
||||
|
||||
TSMaster m0 = new TSMaster();
|
||||
m0.setId(10000);
|
||||
m0.setName("master1");
|
||||
|
||||
Ebean.save(m0);
|
||||
DB.save(m0);
|
||||
|
||||
TSDetail tsDetail = new TSDetail("master1 detail1");
|
||||
TSDetail tsDetail = new TSDetail("m4 d1");
|
||||
tsDetail.setId(10000);
|
||||
tsDetail.setMaster(m0);
|
||||
|
||||
Ebean.save(tsDetail);
|
||||
DB.save(tsDetail);
|
||||
|
||||
TSDetail fetchedDetail = Ebean.find(TSDetail.class).setId(10000).fetch("master").findOne();
|
||||
TSDetail fetchedDetail = DB.find(TSDetail.class).setId(10000).fetch("master").findOne();
|
||||
|
||||
Assert.assertNotNull(fetchedDetail);
|
||||
assertNotNull(fetchedDetail);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user