Fix RIGHT OUTER attribute-joins are not supported
This commit is contained in:
parent
da625e18a9
commit
09266c7ae1
|
@ -1500,10 +1500,6 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
|||
sqmRoot.addSqmJoin( join );
|
||||
}
|
||||
else {
|
||||
if ( joinType == SqmJoinType.RIGHT ) {
|
||||
throw new SemanticException( "RIGHT OUTER attribute-joins are not supported : " + parserJoin.getText() );
|
||||
}
|
||||
|
||||
if ( getCreationOptions().useStrictJpaCompliance() ) {
|
||||
if ( join.getExplicitAlias() != null ){
|
||||
//noinspection rawtypes
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.hibernate.test.inheritance;
|
||||
package org.hibernate.orm.test.inheritance;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
@ -14,35 +13,33 @@ import javax.persistence.UniqueConstraint;
|
|||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.RequiresDialect;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.Setting;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Vlad Paln
|
||||
* @author Nathan Xu
|
||||
*/
|
||||
@TestForIssue( jiraKey = "HHH-14234" )
|
||||
@TestForIssue(jiraKey = "HHH-14234")
|
||||
@RequiresDialect(
|
||||
value = H2Dialect.class,
|
||||
comment = "This test relies on 'hibernate.hbm2ddl.halt_on_error', only tested on h2; " +
|
||||
"other dialects might be broken due to irrelevant reason (e.g. not supporting 'if exists' while dropping tables)."
|
||||
)
|
||||
public class DenormalizedTablePhysicalIncludedTableConstraintTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected void addSettings(Map settings) {
|
||||
settings.put( AvailableSettings.HBM2DDL_HALT_ON_ERROR, Boolean.TRUE.toString() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
SuperClass.class,
|
||||
SubClass.class
|
||||
};
|
||||
}
|
||||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
DenormalizedTablePhysicalIncludedTableConstraintTest.SuperClass.class,
|
||||
DenormalizedTablePhysicalIncludedTableConstraintTest.SubClass.class
|
||||
}
|
||||
)
|
||||
@SessionFactory
|
||||
@ServiceRegistry(settings = @Setting( name = AvailableSettings.HBM2DDL_HALT_ON_ERROR, value = "true"))
|
||||
public class DenormalizedTablePhysicalIncludedTableConstraintTest {
|
||||
|
||||
@Test
|
||||
public void testUniqueConstraintFromSupTableNotAppliedToSubTable() {
|
||||
|
@ -52,10 +49,10 @@ public class DenormalizedTablePhysicalIncludedTableConstraintTest extends BaseNo
|
|||
|
||||
@Entity(name = "SuperClass")
|
||||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
|
||||
@Table( name = "supTable",
|
||||
@Table(name = "supTable",
|
||||
uniqueConstraints = {
|
||||
@UniqueConstraint( name = "UK",
|
||||
columnNames = {"colOne", "colTwo"})
|
||||
@UniqueConstraint(name = "UK",
|
||||
columnNames = { "colOne", "colTwo" })
|
||||
}
|
||||
)
|
||||
static class SuperClass implements Serializable {
|
||||
|
@ -72,7 +69,7 @@ public class DenormalizedTablePhysicalIncludedTableConstraintTest extends BaseNo
|
|||
}
|
||||
|
||||
@Entity(name = "SubClass")
|
||||
@Table( name = "subTable" )
|
||||
@Table(name = "subTable")
|
||||
static class SubClass extends SuperClass {
|
||||
|
||||
@Column(name = "colThree")
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.inheritance;
|
||||
package org.hibernate.orm.test.inheritance;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -27,30 +27,43 @@ import javax.persistence.criteria.ParameterExpression;
|
|||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.testing.FailureExpected;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.FailureExpected;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@TestForIssue(jiraKey = "HHH-14103")
|
||||
public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFunctionalTestCase {
|
||||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
TransientOverrideAsPersistentJoined.Employee.class,
|
||||
TransientOverrideAsPersistentJoined.Editor.class,
|
||||
TransientOverrideAsPersistentJoined.Writer.class,
|
||||
TransientOverrideAsPersistentJoined.Group.class,
|
||||
TransientOverrideAsPersistentJoined.Job.class
|
||||
}
|
||||
)
|
||||
@SessionFactory
|
||||
public class TransientOverrideAsPersistentJoined {
|
||||
|
||||
@Test
|
||||
public void testFindByRootClass() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testFindByRootClass(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Employee editor = session.find( Employee.class, "Jane Smith" );
|
||||
assertNotNull( editor );
|
||||
assertEquals( "Senior Editor", editor.getTitle() );
|
||||
final Employee writer = session.find( Employee.class, "John Smith" );
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertEquals( "Writing", writer.getTitle() );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
final Group group = ( (Writer) writer ).getGroup();
|
||||
|
@ -59,12 +72,12 @@ public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFuncti
|
|||
assertSame( editor, jobEditor.getEmployee() );
|
||||
final Job jobWriter = session.find( Job.class, "Write" );
|
||||
assertSame( writer, jobWriter.getEmployee() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindBySubclass() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testFindBySubclass(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Editor editor = session.find( Editor.class, "Jane Smith" );
|
||||
assertNotNull( editor );
|
||||
assertEquals( "Senior Editor", editor.getTitle() );
|
||||
|
@ -77,18 +90,19 @@ public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFuncti
|
|||
assertSame( editor, jobEditor.getEmployee() );
|
||||
final Job jobWriter = session.find( Job.class, "Write" );
|
||||
assertSame( writer, jobWriter.getEmployee() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByRootClass() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testQueryByRootClass(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final List<Employee> employees = session.createQuery( "from Employee", Employee.class )
|
||||
.getResultList();
|
||||
assertEquals( 2, employees.size() );
|
||||
employees.sort( Comparator.comparing( Employee::getName ) );
|
||||
assertTrue( Editor.class.isInstance( employees.get( 0 ) ) );
|
||||
assertTrue( Writer.class.isInstance( employees.get( 1 ) ) );
|
||||
assertThat( employees.get( 0 ), instanceOf( Editor.class ) );
|
||||
assertThat( employees.get( 1 ), instanceOf( Writer.class ) );
|
||||
|
||||
final Editor editor = (Editor) employees.get( 0 );
|
||||
assertEquals( "Senior Editor", editor.getTitle() );
|
||||
final Writer writer = (Writer) employees.get( 1 );
|
||||
|
@ -96,65 +110,71 @@ public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFuncti
|
|||
assertNotNull( writer.getGroup() );
|
||||
final Group group = writer.getGroup();
|
||||
assertEquals( writer.getTitle(), group.getName() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-12981")
|
||||
public void testQueryByRootClassAndOverridenProperty() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
@FailureExpected(jiraKey = "HHH-12981")
|
||||
public void testQueryByRootClassAndOverridenProperty(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Employee editor = session.createQuery( "from Employee where title=:title", Employee.class )
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Employee writer = session.createQuery( "from Employee where title=:title", Employee.class )
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup() .getName() );
|
||||
});
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup().getName() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-12981")
|
||||
public void testQueryByRootClassAndOverridenPropertyTreat() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
final Employee editor = session.createQuery( "from Employee e where treat( e as Editor ).title=:title", Employee.class )
|
||||
@FailureExpected(jiraKey = "HHH-12981")
|
||||
public void testQueryByRootClassAndOverridenPropertyTreat(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Employee editor = session.createQuery(
|
||||
"from Employee e where treat( e as Editor ).title=:title",
|
||||
Employee.class
|
||||
)
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Employee writer = session.createQuery( "from Employee e where treat( e as Writer).title=:title", Employee.class )
|
||||
final Employee writer = session.createQuery(
|
||||
"from Employee e where treat( e as Writer).title=:title",
|
||||
Employee.class
|
||||
)
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup() .getName() );
|
||||
});
|
||||
}
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup().getName() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryBySublassAndOverridenProperty() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testQueryBySublassAndOverridenProperty(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Editor editor = session.createQuery( "from Editor where title=:title", Editor.class )
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Writer writer = session.createQuery( "from Writer where title=:title", Writer.class )
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertNotNull( writer.getGroup() );
|
||||
assertEquals( writer.getTitle(), writer.getGroup().getName() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-12981")
|
||||
public void testCriteriaQueryByRootClassAndOverridenProperty() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
@FailureExpected(jiraKey = "HHH-12981")
|
||||
public void testCriteriaQueryByRootClassAndOverridenProperty(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
|
||||
final CriteriaBuilder builder = session.getCriteriaBuilder();
|
||||
|
||||
|
@ -170,7 +190,7 @@ public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFuncti
|
|||
final Employee editor = session.createQuery( query )
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Predicate predicateWriter = builder.equal(
|
||||
builder.treat( root, Writer.class ).get( "title" ),
|
||||
|
@ -180,20 +200,20 @@ public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFuncti
|
|||
final Employee writer = session.createQuery( query )
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup() .getName() );
|
||||
});
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup().getName() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setupData() {
|
||||
@BeforeEach
|
||||
public void setupData(SessionFactoryScope scope) {
|
||||
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
Job jobEditor = new Job("Edit");
|
||||
jobEditor.setEmployee(new Editor("Jane Smith", "Senior Editor"));
|
||||
Job jobWriter= new Job("Write");
|
||||
jobWriter.setEmployee(new Writer("John Smith", new Group("Writing")));
|
||||
scope.inTransaction( session -> {
|
||||
Job jobEditor = new Job( "Edit" );
|
||||
jobEditor.setEmployee( new Editor( "Jane Smith", "Senior Editor" ) );
|
||||
Job jobWriter = new Job( "Write" );
|
||||
jobWriter.setEmployee( new Writer( "John Smith", new Group( "Writing" ) ) );
|
||||
|
||||
Employee editor = jobEditor.getEmployee();
|
||||
Employee writer = jobWriter.getEmployee();
|
||||
|
@ -204,39 +224,28 @@ public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFuncti
|
|||
session.persist( writer );
|
||||
session.persist( jobEditor );
|
||||
session.persist( jobWriter );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanupData() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
@AfterEach
|
||||
public void cleanupData(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
session.createQuery( "delete from Job" ).executeUpdate();
|
||||
session.createQuery( "delete from Employee" ).executeUpdate();
|
||||
session.createQuery( "delete from Group" ).executeUpdate();
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
Employee.class,
|
||||
Editor.class,
|
||||
Writer.class,
|
||||
Group.class,
|
||||
Job.class
|
||||
};
|
||||
}
|
||||
|
||||
@Entity(name="Employee")
|
||||
@Entity(name = "Employee")
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@DiscriminatorColumn(name="department")
|
||||
@DiscriminatorColumn(name = "department")
|
||||
public static abstract class Employee {
|
||||
private String name;
|
||||
private String title;
|
||||
|
||||
protected Employee(String name) {
|
||||
this();
|
||||
setName(name);
|
||||
setName( name );
|
||||
}
|
||||
|
||||
@Id
|
||||
|
@ -265,7 +274,7 @@ public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFuncti
|
|||
@Entity(name = "Editor")
|
||||
public static class Editor extends Employee {
|
||||
public Editor(String name, String title) {
|
||||
super(name);
|
||||
super( name );
|
||||
setTitle( title );
|
||||
}
|
||||
|
||||
|
@ -289,8 +298,8 @@ public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFuncti
|
|||
private Group group;
|
||||
|
||||
public Writer(String name, Group group) {
|
||||
super(name);
|
||||
setGroup(group);
|
||||
super( name );
|
||||
setGroup( group );
|
||||
}
|
||||
|
||||
// Cannot have a constraint on e_title because
|
||||
|
@ -327,9 +336,11 @@ public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFuncti
|
|||
public static class Group {
|
||||
private String name;
|
||||
|
||||
private String details;
|
||||
|
||||
public Group(String name) {
|
||||
this();
|
||||
setName(name);
|
||||
setName( name );
|
||||
}
|
||||
|
||||
@Id
|
||||
|
@ -350,10 +361,11 @@ public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFuncti
|
|||
public static class Job {
|
||||
private String name;
|
||||
private Employee employee;
|
||||
private String description;
|
||||
|
||||
public Job(String name) {
|
||||
this();
|
||||
setName(name);
|
||||
setName( name );
|
||||
}
|
||||
|
||||
@Id
|
||||
|
@ -362,7 +374,7 @@ public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFuncti
|
|||
}
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name="employee_name")
|
||||
@JoinColumn(name = "employee_name")
|
||||
public Employee getEmployee() {
|
||||
return employee;
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.inheritance;
|
||||
package org.hibernate.orm.test.inheritance;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.Column;
|
||||
|
@ -28,28 +28,41 @@ import javax.persistence.criteria.Predicate;
|
|||
import javax.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@TestForIssue(jiraKey = "HHH-14103")
|
||||
public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfigCoreFunctionalTestCase {
|
||||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
TransientOverrideAsPersistentMappedSuperclass.Employee.class,
|
||||
TransientOverrideAsPersistentMappedSuperclass.Editor.class,
|
||||
TransientOverrideAsPersistentMappedSuperclass.Writer.class,
|
||||
TransientOverrideAsPersistentMappedSuperclass.Group.class,
|
||||
TransientOverrideAsPersistentMappedSuperclass.Job.class
|
||||
}
|
||||
)
|
||||
@SessionFactory
|
||||
public class TransientOverrideAsPersistentMappedSuperclass {
|
||||
|
||||
@Test
|
||||
public void testFindByRootClass() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testFindByRootClass(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Employee editor = session.find( Employee.class, "Jane Smith" );
|
||||
assertNotNull( editor );
|
||||
assertEquals( "Senior Editor", editor.getTitle() );
|
||||
final Employee writer = session.find( Employee.class, "John Smith" );
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertEquals( "Writing", writer.getTitle() );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
final Group group = ( (Writer) writer ).getGroup();
|
||||
|
@ -58,12 +71,12 @@ public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfig
|
|||
assertSame( editor, jobEditor.getEmployee() );
|
||||
final Job jobWriter = session.find( Job.class, "Write" );
|
||||
assertSame( writer, jobWriter.getEmployee() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindBySubclass() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testFindBySubclass(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Editor editor = session.find( Editor.class, "Jane Smith" );
|
||||
assertNotNull( editor );
|
||||
assertEquals( "Senior Editor", editor.getTitle() );
|
||||
|
@ -76,17 +89,17 @@ public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfig
|
|||
assertSame( editor, jobEditor.getEmployee() );
|
||||
final Job jobWriter = session.find( Job.class, "Write" );
|
||||
assertSame( writer, jobWriter.getEmployee() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByRootClass() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testQueryByRootClass(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final List<Employee> employees = session.createQuery( "from Employee", Employee.class )
|
||||
.getResultList();
|
||||
assertEquals( 2, employees.size() );
|
||||
assertTrue( Editor.class.isInstance( employees.get( 0 ) ) );
|
||||
assertTrue( Writer.class.isInstance( employees.get( 1 ) ) );
|
||||
assertThat( employees.get( 0 ), instanceOf( Editor.class ) );
|
||||
assertThat( employees.get( 1 ), instanceOf( Writer.class ) );
|
||||
final Editor editor = (Editor) employees.get( 0 );
|
||||
assertEquals( "Senior Editor", editor.getTitle() );
|
||||
final Writer writer = (Writer) employees.get( 1 );
|
||||
|
@ -94,62 +107,68 @@ public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfig
|
|||
assertNotNull( writer.getGroup() );
|
||||
final Group group = writer.getGroup();
|
||||
assertEquals( writer.getTitle(), group.getName() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByRootClassAndOverridenProperty() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testQueryByRootClassAndOverridenProperty(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Employee editor = session.createQuery( "from Employee where title=:title", Employee.class )
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Employee writer = session.createQuery( "from Employee where title=:title", Employee.class )
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup() .getName() );
|
||||
});
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup().getName() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByRootClassAndOverridenPropertyTreat() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
final Employee editor = session.createQuery( "from Employee e where treat( e as Editor ).title=:title", Employee.class )
|
||||
public void testQueryByRootClassAndOverridenPropertyTreat(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Employee editor = session.createQuery(
|
||||
"from Employee e where treat( e as Editor ).title=:title",
|
||||
Employee.class
|
||||
)
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Employee writer = session.createQuery( "from Employee e where treat( e as Writer).title=:title", Employee.class )
|
||||
final Employee writer = session.createQuery(
|
||||
"from Employee e where treat( e as Writer).title=:title",
|
||||
Employee.class
|
||||
)
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup() .getName() );
|
||||
});
|
||||
}
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup().getName() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryBySublassAndOverridenProperty() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testQueryBySublassAndOverridenProperty(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Editor editor = session.createQuery( "from Editor where title=:title", Editor.class )
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Writer writer = session.createQuery( "from Writer where title=:title", Writer.class )
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertNotNull( writer.getGroup() );
|
||||
assertEquals( writer.getTitle(), writer.getGroup().getName() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCriteriaQueryByRootClassAndOverridenProperty() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testCriteriaQueryByRootClassAndOverridenProperty(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
|
||||
final CriteriaBuilder builder = session.getCriteriaBuilder();
|
||||
|
||||
|
@ -165,7 +184,7 @@ public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfig
|
|||
final Employee editor = session.createQuery( query )
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Predicate predicateWriter = builder.equal(
|
||||
builder.treat( root, Writer.class ).get( "title" ),
|
||||
|
@ -175,20 +194,19 @@ public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfig
|
|||
final Employee writer = session.createQuery( query )
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup() .getName() );
|
||||
});
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup().getName() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setupData() {
|
||||
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
Job jobEditor = new Job("Edit");
|
||||
jobEditor.setEmployee(new Editor("Jane Smith", "Senior Editor"));
|
||||
Job jobWriter= new Job("Write");
|
||||
jobWriter.setEmployee(new Writer("John Smith", new Group("Writing")));
|
||||
@BeforeEach
|
||||
public void setupData(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
Job jobEditor = new Job( "Edit" );
|
||||
jobEditor.setEmployee( new Editor( "Jane Smith", "Senior Editor" ) );
|
||||
Job jobWriter = new Job( "Write" );
|
||||
jobWriter.setEmployee( new Writer( "John Smith", new Group( "Writing" ) ) );
|
||||
|
||||
Employee editor = jobEditor.getEmployee();
|
||||
Employee writer = jobWriter.getEmployee();
|
||||
|
@ -199,27 +217,16 @@ public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfig
|
|||
session.persist( writer );
|
||||
session.persist( jobEditor );
|
||||
session.persist( jobWriter );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanupData() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
@AfterEach
|
||||
public void cleanupData(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
session.createQuery( "delete from Job" ).executeUpdate();
|
||||
session.createQuery( "delete from Employee" ).executeUpdate();
|
||||
session.createQuery( "delete from Group" ).executeUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
Employee.class,
|
||||
Editor.class,
|
||||
Writer.class,
|
||||
Group.class,
|
||||
Job.class
|
||||
};
|
||||
} );
|
||||
}
|
||||
|
||||
@MappedSuperclass
|
||||
|
@ -236,15 +243,15 @@ public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfig
|
|||
}
|
||||
}
|
||||
|
||||
@Entity(name="Employee")
|
||||
@Entity(name = "Employee")
|
||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||
@DiscriminatorColumn(name="department")
|
||||
@DiscriminatorColumn(name = "department")
|
||||
public static abstract class Employee extends AbstractEmployee {
|
||||
private String name;
|
||||
|
||||
protected Employee(String name) {
|
||||
this();
|
||||
setName(name);
|
||||
setName( name );
|
||||
}
|
||||
|
||||
@Id
|
||||
|
@ -264,7 +271,7 @@ public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfig
|
|||
@Entity(name = "Editor")
|
||||
public static class Editor extends Employee {
|
||||
public Editor(String name, String title) {
|
||||
super(name);
|
||||
super( name );
|
||||
setTitle( title );
|
||||
}
|
||||
|
||||
|
@ -288,8 +295,8 @@ public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfig
|
|||
private Group group;
|
||||
|
||||
public Writer(String name, Group group) {
|
||||
super(name);
|
||||
setGroup(group);
|
||||
super( name );
|
||||
setGroup( group );
|
||||
}
|
||||
|
||||
// Cannot have a constraint on e_title because
|
||||
|
@ -326,9 +333,11 @@ public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfig
|
|||
public static class Group {
|
||||
private String name;
|
||||
|
||||
private String desctiption;
|
||||
|
||||
public Group(String name) {
|
||||
this();
|
||||
setName(name);
|
||||
setName( name );
|
||||
}
|
||||
|
||||
@Id
|
||||
|
@ -350,9 +359,11 @@ public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfig
|
|||
private String name;
|
||||
private Employee employee;
|
||||
|
||||
private String description;
|
||||
|
||||
public Job(String name) {
|
||||
this();
|
||||
setName(name);
|
||||
setName( name );
|
||||
}
|
||||
|
||||
@Id
|
||||
|
@ -361,7 +372,7 @@ public class TransientOverrideAsPersistentMappedSuperclass extends BaseNonConfig
|
|||
}
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name="employee_name")
|
||||
@JoinColumn(name = "employee_name")
|
||||
public Employee getEmployee() {
|
||||
return employee;
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.inheritance;
|
||||
package org.hibernate.orm.test.inheritance;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.Column;
|
||||
|
@ -26,30 +26,41 @@ import javax.persistence.criteria.ParameterExpression;
|
|||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
@TestForIssue(jiraKey = "HHH-14103")
|
||||
public class TransientOverrideAsPersistentSingleTable extends BaseNonConfigCoreFunctionalTestCase {
|
||||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
TransientOverrideAsPersistentSingleTable.Employee.class,
|
||||
TransientOverrideAsPersistentSingleTable.Editor.class,
|
||||
TransientOverrideAsPersistentSingleTable.Writer.class,
|
||||
TransientOverrideAsPersistentSingleTable.Group.class,
|
||||
TransientOverrideAsPersistentSingleTable.Job.class
|
||||
}
|
||||
)
|
||||
@SessionFactory
|
||||
public class TransientOverrideAsPersistentSingleTable {
|
||||
|
||||
@Test
|
||||
public void testFindByRootClass() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testFindByRootClass(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Employee editor = session.find( Employee.class, "Jane Smith" );
|
||||
assertNotNull( editor );
|
||||
assertEquals( "Senior Editor", editor.getTitle() );
|
||||
final Employee writer = session.find( Employee.class, "John Smith" );
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertEquals( "Writing", writer.getTitle() );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
final Group group = ( (Writer) writer ).getGroup();
|
||||
|
@ -58,12 +69,12 @@ public class TransientOverrideAsPersistentSingleTable extends BaseNonConfigCoreF
|
|||
assertSame( editor, jobEditor.getEmployee() );
|
||||
final Job jobWriter = session.find( Job.class, "Write" );
|
||||
assertSame( writer, jobWriter.getEmployee() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindBySubclass() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testFindBySubclass(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Editor editor = session.find( Editor.class, "Jane Smith" );
|
||||
assertNotNull( editor );
|
||||
assertEquals( "Senior Editor", editor.getTitle() );
|
||||
|
@ -76,17 +87,17 @@ public class TransientOverrideAsPersistentSingleTable extends BaseNonConfigCoreF
|
|||
assertSame( editor, jobEditor.getEmployee() );
|
||||
final Job jobWriter = session.find( Job.class, "Write" );
|
||||
assertSame( writer, jobWriter.getEmployee() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByRootClass() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testQueryByRootClass(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final List<Employee> employees = session.createQuery( "from Employee", Employee.class )
|
||||
.getResultList();
|
||||
assertEquals( 2, employees.size() );
|
||||
assertTrue( Editor.class.isInstance( employees.get( 0 ) ) );
|
||||
assertTrue( Writer.class.isInstance( employees.get( 1 ) ) );
|
||||
assertThat( employees.get( 0 ), instanceOf( Editor.class ) );
|
||||
assertThat( employees.get( 1 ), instanceOf( Writer.class ) );
|
||||
final Editor editor = (Editor) employees.get( 0 );
|
||||
assertEquals( "Senior Editor", editor.getTitle() );
|
||||
final Writer writer = (Writer) employees.get( 1 );
|
||||
|
@ -94,63 +105,68 @@ public class TransientOverrideAsPersistentSingleTable extends BaseNonConfigCoreF
|
|||
assertNotNull( writer.getGroup() );
|
||||
final Group group = writer.getGroup();
|
||||
assertEquals( writer.getTitle(), group.getName() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByRootClassAndOverridenProperty() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testQueryByRootClassAndOverridenProperty(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Employee editor = session.createQuery( "from Employee where title=:title", Employee.class )
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Employee writer = session.createQuery( "from Employee where title=:title", Employee.class )
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup() .getName() );
|
||||
});
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup().getName() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByRootClassAndOverridenPropertyTreat() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
final Employee editor = session.createQuery( "from Employee e where treat( e as Editor ).title=:title", Employee.class )
|
||||
public void testQueryByRootClassAndOverridenPropertyTreat(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Employee editor = session.createQuery(
|
||||
"from Employee e where treat( e as Editor ).title=:title",
|
||||
Employee.class
|
||||
)
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Employee writer = session.createQuery( "from Employee e where treat( e as Writer).title=:title", Employee.class )
|
||||
final Employee writer = session.createQuery(
|
||||
"from Employee e where treat( e as Writer).title=:title",
|
||||
Employee.class
|
||||
)
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup() .getName() );
|
||||
});
|
||||
}
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup().getName() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryBySublassAndOverridenProperty() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testQueryBySublassAndOverridenProperty(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Editor editor = session.createQuery( "from Editor where title=:title", Editor.class )
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Writer writer = session.createQuery( "from Writer where title=:title", Writer.class )
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertNotNull( writer.getGroup() );
|
||||
assertEquals( writer.getTitle(), writer.getGroup().getName() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCriteriaQueryByRootClassAndOverridenProperty() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
|
||||
public void testCriteriaQueryByRootClassAndOverridenProperty(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final CriteriaBuilder builder = session.getCriteriaBuilder();
|
||||
|
||||
final CriteriaQuery<Employee> query = builder.createQuery( Employee.class );
|
||||
|
@ -165,7 +181,7 @@ public class TransientOverrideAsPersistentSingleTable extends BaseNonConfigCoreF
|
|||
final Employee editor = session.createQuery( query )
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Predicate predicateWriter = builder.equal(
|
||||
builder.treat( root, Writer.class ).get( "title" ),
|
||||
|
@ -175,20 +191,19 @@ public class TransientOverrideAsPersistentSingleTable extends BaseNonConfigCoreF
|
|||
final Employee writer = session.createQuery( query )
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup() .getName() );
|
||||
});
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup().getName() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setupData() {
|
||||
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
Job jobEditor = new Job("Edit");
|
||||
jobEditor.setEmployee(new Editor("Jane Smith", "Senior Editor"));
|
||||
Job jobWriter= new Job("Write");
|
||||
jobWriter.setEmployee(new Writer("John Smith", new Group("Writing")));
|
||||
@BeforeEach
|
||||
public void setupData(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
Job jobEditor = new Job( "Edit" );
|
||||
jobEditor.setEmployee( new Editor( "Jane Smith", "Senior Editor" ) );
|
||||
Job jobWriter = new Job( "Write" );
|
||||
jobWriter.setEmployee( new Writer( "John Smith", new Group( "Writing" ) ) );
|
||||
|
||||
Employee editor = jobEditor.getEmployee();
|
||||
Employee writer = jobWriter.getEmployee();
|
||||
|
@ -199,39 +214,28 @@ public class TransientOverrideAsPersistentSingleTable extends BaseNonConfigCoreF
|
|||
session.persist( writer );
|
||||
session.persist( jobEditor );
|
||||
session.persist( jobWriter );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanupData() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
@AfterEach
|
||||
public void cleanupData(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
session.createQuery( "delete from Job" ).executeUpdate();
|
||||
session.createQuery( "delete from Employee" ).executeUpdate();
|
||||
session.createQuery( "delete from Group" ).executeUpdate();
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
Employee.class,
|
||||
Editor.class,
|
||||
Writer.class,
|
||||
Group.class,
|
||||
Job.class
|
||||
};
|
||||
}
|
||||
|
||||
@Entity(name="Employee")
|
||||
@Entity(name = "Employee")
|
||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||
@DiscriminatorColumn(name="department")
|
||||
@DiscriminatorColumn(name = "department")
|
||||
public static abstract class Employee {
|
||||
private String name;
|
||||
private String title;
|
||||
|
||||
protected Employee(String name) {
|
||||
this();
|
||||
setName(name);
|
||||
setName( name );
|
||||
}
|
||||
|
||||
@Id
|
||||
|
@ -260,7 +264,7 @@ public class TransientOverrideAsPersistentSingleTable extends BaseNonConfigCoreF
|
|||
@Entity(name = "Editor")
|
||||
public static class Editor extends Employee {
|
||||
public Editor(String name, String title) {
|
||||
super(name);
|
||||
super( name );
|
||||
setTitle( title );
|
||||
}
|
||||
|
||||
|
@ -284,8 +288,8 @@ public class TransientOverrideAsPersistentSingleTable extends BaseNonConfigCoreF
|
|||
private Group group;
|
||||
|
||||
public Writer(String name, Group group) {
|
||||
super(name);
|
||||
setGroup(group);
|
||||
super( name );
|
||||
setGroup( group );
|
||||
}
|
||||
|
||||
// Cannot have a constraint on e_title because
|
||||
|
@ -321,10 +325,11 @@ public class TransientOverrideAsPersistentSingleTable extends BaseNonConfigCoreF
|
|||
@Table(name = "WorkGroup")
|
||||
public static class Group {
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
public Group(String name) {
|
||||
this();
|
||||
setName(name);
|
||||
setName( name );
|
||||
}
|
||||
|
||||
@Id
|
||||
|
@ -345,10 +350,11 @@ public class TransientOverrideAsPersistentSingleTable extends BaseNonConfigCoreF
|
|||
public static class Job {
|
||||
private String name;
|
||||
private Employee employee;
|
||||
private String description;
|
||||
|
||||
public Job(String name) {
|
||||
this();
|
||||
setName(name);
|
||||
setName( name );
|
||||
}
|
||||
|
||||
@Id
|
||||
|
@ -357,7 +363,7 @@ public class TransientOverrideAsPersistentSingleTable extends BaseNonConfigCoreF
|
|||
}
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name="employee_name")
|
||||
@JoinColumn(name = "employee_name")
|
||||
public Employee getEmployee() {
|
||||
return employee;
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.inheritance;
|
||||
package org.hibernate.orm.test.inheritance;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -28,28 +28,40 @@ import javax.persistence.criteria.Predicate;
|
|||
import javax.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
@TestForIssue(jiraKey = "HHH-14103")
|
||||
public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCoreFunctionalTestCase {
|
||||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
TransientOverrideAsPersistentTablePerClass.Employee.class,
|
||||
TransientOverrideAsPersistentTablePerClass.Editor.class,
|
||||
TransientOverrideAsPersistentTablePerClass.Writer.class,
|
||||
TransientOverrideAsPersistentTablePerClass.Group.class,
|
||||
TransientOverrideAsPersistentTablePerClass.Job.class
|
||||
}
|
||||
)
|
||||
@SessionFactory
|
||||
public class TransientOverrideAsPersistentTablePerClass {
|
||||
|
||||
@Test
|
||||
public void testFindByRootClass() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testFindByRootClass(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Employee editor = session.find( Employee.class, "Jane Smith" );
|
||||
assertNotNull( editor );
|
||||
assertEquals( "Senior Editor", editor.getTitle() );
|
||||
final Employee writer = session.find( Employee.class, "John Smith" );
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertEquals( "Writing", writer.getTitle() );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
final Group group = ( (Writer) writer ).getGroup();
|
||||
|
@ -58,12 +70,12 @@ public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCor
|
|||
assertSame( editor, jobEditor.getEmployee() );
|
||||
final Job jobWriter = session.find( Job.class, "Write" );
|
||||
assertSame( writer, jobWriter.getEmployee() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindBySubclass() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testFindBySubclass(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Editor editor = session.find( Editor.class, "Jane Smith" );
|
||||
assertNotNull( editor );
|
||||
assertEquals( "Senior Editor", editor.getTitle() );
|
||||
|
@ -76,18 +88,18 @@ public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCor
|
|||
assertSame( editor, jobEditor.getEmployee() );
|
||||
final Job jobWriter = session.find( Job.class, "Write" );
|
||||
assertSame( writer, jobWriter.getEmployee() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByRootClass() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testQueryByRootClass(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final List<Employee> employees = session.createQuery( "from Employee", Employee.class )
|
||||
.getResultList();
|
||||
assertEquals( 2, employees.size() );
|
||||
employees.sort( Comparator.comparing( Employee::getName ) );
|
||||
assertTrue( Editor.class.isInstance( employees.get( 0 ) ) );
|
||||
assertTrue( Writer.class.isInstance( employees.get( 1 ) ) );
|
||||
assertThat( employees.get( 0 ), instanceOf( Editor.class ) );
|
||||
assertThat( employees.get( 1 ), instanceOf( Writer.class ) );
|
||||
final Editor editor = (Editor) employees.get( 0 );
|
||||
assertEquals( "Senior Editor", editor.getTitle() );
|
||||
final Writer writer = (Writer) employees.get( 1 );
|
||||
|
@ -95,62 +107,68 @@ public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCor
|
|||
assertNotNull( writer.getGroup() );
|
||||
final Group group = writer.getGroup();
|
||||
assertEquals( writer.getTitle(), group.getName() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByRootClassAndOverridenProperty() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testQueryByRootClassAndOverridenProperty(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Employee editor = session.createQuery( "from Employee where title=:title", Employee.class )
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Employee writer = session.createQuery( "from Employee where title=:title", Employee.class )
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup() .getName() );
|
||||
});
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup().getName() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByRootClassAndOverridenPropertyTreat() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
final Employee editor = session.createQuery( "from Employee e where treat( e as Editor ).title=:title", Employee.class )
|
||||
public void testQueryByRootClassAndOverridenPropertyTreat(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Employee editor = session.createQuery(
|
||||
"from Employee e where treat( e as Editor ).title=:title",
|
||||
Employee.class
|
||||
)
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Employee writer = session.createQuery( "from Employee e where treat( e as Writer).title=:title", Employee.class )
|
||||
final Employee writer = session.createQuery(
|
||||
"from Employee e where treat( e as Writer).title=:title",
|
||||
Employee.class
|
||||
)
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup() .getName() );
|
||||
});
|
||||
}
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup().getName() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryBySublassAndOverridenProperty() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testQueryBySublassAndOverridenProperty(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final Editor editor = session.createQuery( "from Editor where title=:title", Editor.class )
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Writer writer = session.createQuery( "from Writer where title=:title", Writer.class )
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertNotNull( writer.getGroup() );
|
||||
assertEquals( writer.getTitle(), writer.getGroup().getName() );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCriteriaQueryByRootClassAndOverridenProperty() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void testCriteriaQueryByRootClassAndOverridenProperty(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
|
||||
final CriteriaBuilder builder = session.getCriteriaBuilder();
|
||||
|
||||
|
@ -166,7 +184,7 @@ public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCor
|
|||
final Employee editor = session.createQuery( query )
|
||||
.setParameter( "title", "Senior Editor" )
|
||||
.getSingleResult();
|
||||
assertTrue( Editor.class.isInstance( editor ) );
|
||||
assertThat( editor, instanceOf( Editor.class ) );
|
||||
|
||||
final Predicate predicateWriter = builder.equal(
|
||||
builder.treat( root, Writer.class ).get( "title" ),
|
||||
|
@ -176,20 +194,19 @@ public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCor
|
|||
final Employee writer = session.createQuery( query )
|
||||
.setParameter( "title", "Writing" )
|
||||
.getSingleResult();
|
||||
assertTrue( Writer.class.isInstance( writer ) );
|
||||
assertThat( writer, instanceOf( Writer.class ) );
|
||||
assertNotNull( ( (Writer) writer ).getGroup() );
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup() .getName() );
|
||||
});
|
||||
assertEquals( writer.getTitle(), ( (Writer) writer ).getGroup().getName() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setupData() {
|
||||
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
Job jobEditor = new Job("Edit");
|
||||
jobEditor.setEmployee(new Editor("Jane Smith", "Senior Editor"));
|
||||
Job jobWriter= new Job("Write");
|
||||
jobWriter.setEmployee(new Writer("John Smith", new Group("Writing")));
|
||||
@BeforeEach
|
||||
public void setupData(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
Job jobEditor = new Job( "Edit" );
|
||||
jobEditor.setEmployee( new Editor( "Jane Smith", "Senior Editor" ) );
|
||||
Job jobWriter = new Job( "Write" );
|
||||
jobWriter.setEmployee( new Writer( "John Smith", new Group( "Writing" ) ) );
|
||||
|
||||
Employee editor = jobEditor.getEmployee();
|
||||
Employee writer = jobWriter.getEmployee();
|
||||
|
@ -200,39 +217,28 @@ public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCor
|
|||
session.persist( writer );
|
||||
session.persist( jobEditor );
|
||||
session.persist( jobWriter );
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanupData() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
@AfterEach
|
||||
public void cleanupData(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
session.createQuery( "delete from Job" ).executeUpdate();
|
||||
session.createQuery( "delete from Employee" ).executeUpdate();
|
||||
session.createQuery( "delete from Group" ).executeUpdate();
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
Employee.class,
|
||||
Editor.class,
|
||||
Writer.class,
|
||||
Group.class,
|
||||
Job.class
|
||||
};
|
||||
}
|
||||
|
||||
@Entity(name="Employee")
|
||||
@Entity(name = "Employee")
|
||||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
|
||||
@DiscriminatorColumn(name="department")
|
||||
@DiscriminatorColumn(name = "department")
|
||||
public static abstract class Employee {
|
||||
private String name;
|
||||
private String title;
|
||||
|
||||
protected Employee(String name) {
|
||||
this();
|
||||
setName(name);
|
||||
setName( name );
|
||||
}
|
||||
|
||||
@Id
|
||||
|
@ -261,7 +267,7 @@ public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCor
|
|||
@Entity(name = "Editor")
|
||||
public static class Editor extends Employee {
|
||||
public Editor(String name, String title) {
|
||||
super(name);
|
||||
super( name );
|
||||
setTitle( title );
|
||||
}
|
||||
|
||||
|
@ -285,8 +291,8 @@ public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCor
|
|||
private Group group;
|
||||
|
||||
public Writer(String name, Group group) {
|
||||
super(name);
|
||||
setGroup(group);
|
||||
super( name );
|
||||
setGroup( group );
|
||||
}
|
||||
|
||||
// Cannot have a constraint on e_title because
|
||||
|
@ -322,10 +328,11 @@ public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCor
|
|||
@Table(name = "WorkGroup")
|
||||
public static class Group {
|
||||
private String name;
|
||||
private String details;
|
||||
|
||||
public Group(String name) {
|
||||
this();
|
||||
setName(name);
|
||||
setName( name );
|
||||
}
|
||||
|
||||
@Id
|
||||
|
@ -346,10 +353,11 @@ public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCor
|
|||
public static class Job {
|
||||
private String name;
|
||||
private Employee employee;
|
||||
private String details;
|
||||
|
||||
public Job(String name) {
|
||||
this();
|
||||
setName(name);
|
||||
setName( name );
|
||||
}
|
||||
|
||||
@Id
|
||||
|
@ -358,7 +366,7 @@ public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCor
|
|||
}
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name="employee_name")
|
||||
@JoinColumn(name = "employee_name")
|
||||
public Employee getEmployee() {
|
||||
return employee;
|
||||
}
|
|
@ -120,20 +120,44 @@ public class OuterJoinTest extends BaseCoreFunctionalTestCase {
|
|||
em.merge(association);
|
||||
|
||||
em.merge(new A(1L, "a", association));
|
||||
em.merge(new A(2L, "b", association));
|
||||
em.merge(new A(3L, "c", association));
|
||||
// em.merge(new A(2L, "b", association));
|
||||
// em.merge(new A(3L, "c", association));
|
||||
//
|
||||
// em.merge(new B(1L, "d", association));
|
||||
// em.merge(new B(2L, "e", association));
|
||||
// em.merge(new B(3L, "f", association));
|
||||
//
|
||||
// em.merge(new C(1L, "g", association));
|
||||
// em.merge(new C(2L, "h", association));
|
||||
// em.merge(new C(4L, "j", association));
|
||||
//
|
||||
// em.merge(new D(1L, "k", association));
|
||||
// em.merge(new D(2L, "l", association));
|
||||
// em.merge(new D(4L, "m", association));
|
||||
});
|
||||
}
|
||||
|
||||
em.merge(new B(1L, "d", association));
|
||||
em.merge(new B(2L, "e", association));
|
||||
em.merge(new B(3L, "f", association));
|
||||
@Test
|
||||
public void mergeIt(){
|
||||
doInJPA( this::sessionFactory, em -> {
|
||||
Association association = new Association(1l, "association");
|
||||
em.merge(association);
|
||||
|
||||
em.merge(new C(1L, "g", association));
|
||||
em.merge(new C(2L, "h", association));
|
||||
em.merge(new C(4L, "j", association));
|
||||
|
||||
em.merge(new D(1L, "k", association));
|
||||
em.merge(new D(2L, "l", association));
|
||||
em.merge(new D(4L, "m", association));
|
||||
em.merge(new A(1L, "a", association));
|
||||
// em.merge(new A(2L, "b", association));
|
||||
// em.merge(new A(3L, "c", association));
|
||||
//
|
||||
// em.merge(new B(1L, "d", association));
|
||||
// em.merge(new B(2L, "e", association));
|
||||
// em.merge(new B(3L, "f", association));
|
||||
//
|
||||
// em.merge(new C(1L, "g", association));
|
||||
// em.merge(new C(2L, "h", association));
|
||||
// em.merge(new C(4L, "j", association));
|
||||
//
|
||||
// em.merge(new D(1L, "k", association));
|
||||
// em.merge(new D(2L, "l", association));
|
||||
// em.merge(new D(4L, "m", association));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -44,4 +44,11 @@ public @interface RequiresDialect {
|
|||
* the Dialect version
|
||||
*/
|
||||
int version() default -1;
|
||||
|
||||
/**
|
||||
* Comment describing the reason why the dialect is required.
|
||||
*
|
||||
* @return The comment
|
||||
*/
|
||||
String comment() default "";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue