HHH-7534 completed test case
This commit is contained in:
parent
d576bb071f
commit
ca9b917622
|
@ -118,9 +118,4 @@ public abstract class AbstractJPAIndexTest extends BaseCoreFunctionalTestCase {
|
||||||
assertEquals( "importers_id", column.getColumnName().getText() );
|
assertEquals( "importers_id", column.getColumnName().getText() );
|
||||||
assertSame( table, index.getTable() );
|
assertSame( table, index.getTable() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTableGeneratorIndex(){
|
|
||||||
//todo
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ package org.hibernate.test.annotations.index.jpa;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.AttributeOverride;
|
import javax.persistence.AttributeOverride;
|
||||||
import javax.persistence.AttributeOverrides;
|
import javax.persistence.AttributeOverrides;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
|
@ -33,28 +34,37 @@ import javax.persistence.Column;
|
||||||
import javax.persistence.ElementCollection;
|
import javax.persistence.ElementCollection;
|
||||||
import javax.persistence.Embedded;
|
import javax.persistence.Embedded;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Index;
|
import javax.persistence.Index;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.SecondaryTable;
|
import javax.persistence.SecondaryTable;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.TableGenerator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Strong Liu <stliu@hibernate.org>
|
* @author Strong Liu <stliu@hibernate.org>
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(indexes = {
|
@Table(indexes = { @Index(unique = true, columnList = "brand, producer"),
|
||||||
@Index(unique = true, columnList = "brand, producer")
|
@Index(name = "Car_idx", columnList = "since DESC")
|
||||||
, @Index(name = "Car_idx", columnList = "since DESC")
|
|
||||||
})
|
})
|
||||||
|
@TableGenerator(name = "idGen", table = "ID_GEN", valueColumnName="GEN_VALUE",
|
||||||
|
indexes = @Index(columnList = "GEN_VALUE"))
|
||||||
@SecondaryTable(name = "T_DEALER", indexes = @Index(columnList = "dealer_name ASC, rate DESC"))
|
@SecondaryTable(name = "T_DEALER", indexes = @Index(columnList = "dealer_name ASC, rate DESC"))
|
||||||
public class Car {
|
public class Car {
|
||||||
@Id
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.TABLE, generator = "idGen")
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
private String brand;
|
private String brand;
|
||||||
|
|
||||||
private String producer;
|
private String producer;
|
||||||
|
|
||||||
private long since;
|
private long since;
|
||||||
|
|
||||||
@AttributeOverrides({
|
@AttributeOverrides({
|
||||||
@AttributeOverride(name = "name", column = @Column(name = "dealer_name", table = "T_DEALER")),
|
@AttributeOverride(name = "name", column = @Column(name = "dealer_name", table = "T_DEALER")),
|
||||||
@AttributeOverride(name = "rate", column = @Column(table = "T_DEALER"))
|
@AttributeOverride(name = "rate", column = @Column(table = "T_DEALER"))
|
||||||
|
|
|
@ -23,6 +23,18 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.index.jpa;
|
package org.hibernate.test.annotations.index.jpa;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertSame;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
import org.hibernate.metamodel.spi.relational.TableSpecification;
|
||||||
|
import org.hibernate.test.util.SchemaUtil;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Strong Liu <stliu@hibernate.org>
|
* @author Strong Liu <stliu@hibernate.org>
|
||||||
|
@ -37,5 +49,18 @@ public class IndexTest extends AbstractJPAIndexTest {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTableGeneratorIndex(){
|
||||||
|
TableSpecification table = SchemaUtil.getTable( "ID_GEN", metadata() );
|
||||||
|
|
||||||
|
Iterator<org.hibernate.metamodel.spi.relational.Index> indexes = table.getIndexes().iterator();
|
||||||
|
assertTrue( indexes.hasNext() );
|
||||||
|
org.hibernate.metamodel.spi.relational.Index index = indexes.next();
|
||||||
|
assertFalse( indexes.hasNext() );
|
||||||
|
assertTrue( "index name is not generated", StringHelper.isNotEmpty( index.getName() ) );
|
||||||
|
assertEquals( 1, index.getColumnSpan() );
|
||||||
|
org.hibernate.metamodel.spi.relational.Column column = index.getColumns().get( 0 );
|
||||||
|
assertEquals( "GEN_VALUE", column.getColumnName().getText() );
|
||||||
|
assertSame( table, index.getTable() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue