BAEL-4723 Defining Indexes in JPA #2 (#10254)

* BAEL-4723 Defining Indexes in JPA

* unit -> integration test

* whitespaces fix

* tab to space

Co-authored-by: mateusz.szablak <mateusz.szablak@accenture.com>
This commit is contained in:
Mateusz Szablak 2020-11-16 06:26:38 +01:00 committed by GitHub
parent f440cf900c
commit ad30d29ed6
2 changed files with 21 additions and 21 deletions

View File

@ -10,13 +10,13 @@ import java.util.Objects;
@Entity @Entity
@Table(indexes = { @Table(indexes = {
@Index(columnList = "firstName"), @Index(columnList = "firstName"),
@Index(name = "fn_index", columnList = "id"), @Index(name = "fn_index", columnList = "id"),
@Index(name = "multiIndex1", columnList = "firstName, lastName"), @Index(name = "multiIndex1", columnList = "firstName, lastName"),
@Index(name = "multiIndex2", columnList = "lastName, firstName"), @Index(name = "multiIndex2", columnList = "lastName, firstName"),
@Index(name = "multiSortIndex", columnList = "firstName, lastName DESC"), @Index(name = "multiSortIndex", columnList = "firstName, lastName DESC"),
@Index(name = "uniqueIndex", columnList = "firstName", unique = true), @Index(name = "uniqueIndex", columnList = "firstName", unique = true),
@Index(name = "uniqueMultiIndex", columnList = "firstName, lastName", unique = true) @Index(name = "uniqueMultiIndex", columnList = "firstName, lastName", unique = true)
}) })
public class Student implements Serializable { public class Student implements Serializable {
@Id @Id

View File

@ -41,18 +41,18 @@
</properties> </properties>
</persistence-unit> </persistence-unit>
<persistence-unit name="jpa-index"> <persistence-unit name="jpa-index">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.baeldung.jpa.index.Student</class> <class>com.baeldung.jpa.index.Student</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes> <exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties> <properties>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" /> <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:test" /> <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:test" />
<property name="javax.persistence.jdbc.user" value="sa" /> <property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" /> <property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" /> <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" /> <property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="show_sql" value="true" /> <property name="show_sql" value="true" />
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false" /> <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false" />
</properties> </properties>
</persistence-unit> </persistence-unit>
</persistence> </persistence>