Re-enabled additional tests
This commit is contained in:
parent
6ebceedf48
commit
d89b28e1a9
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.jpa.procedure;
|
package org.hibernate.orm.test.jpa.procedure;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -25,6 +25,7 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.dialect.Oracle10gDialect;
|
import org.hibernate.dialect.Oracle10gDialect;
|
||||||
|
import org.hibernate.dialect.OracleDialect;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
@ -41,7 +42,7 @@ import static org.junit.Assert.fail;
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-10756")
|
@TestForIssue(jiraKey = "HHH-10756")
|
||||||
@RequiresDialect(Oracle10gDialect.class)
|
@RequiresDialect(OracleDialect.class)
|
||||||
public class StoreProcedureOutParameterByNameTest extends BaseEntityManagerFunctionalTestCase {
|
public class StoreProcedureOutParameterByNameTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
EntityManagerFactory entityManagerFactory;
|
EntityManagerFactory entityManagerFactory;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.jpa.procedure;
|
package org.hibernate.orm.test.jpa.procedure;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -25,6 +25,7 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.dialect.Oracle10gDialect;
|
import org.hibernate.dialect.Oracle10gDialect;
|
||||||
|
import org.hibernate.dialect.OracleDialect;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
@ -41,7 +42,7 @@ import static org.junit.Assert.fail;
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-10756")
|
@TestForIssue(jiraKey = "HHH-10756")
|
||||||
@RequiresDialect(Oracle10gDialect.class)
|
@RequiresDialect(OracleDialect.class)
|
||||||
public class StoreProcedureOutParameterByPositionTest extends BaseEntityManagerFunctionalTestCase {
|
public class StoreProcedureOutParameterByPositionTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
EntityManagerFactory entityManagerFactory;
|
EntityManagerFactory entityManagerFactory;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.jpa.procedure;
|
package org.hibernate.orm.test.jpa.procedure;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -21,6 +21,7 @@ import jakarta.persistence.StoredProcedureQuery;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.dialect.Oracle10gDialect;
|
import org.hibernate.dialect.Oracle10gDialect;
|
||||||
|
import org.hibernate.dialect.OracleDialect;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
@ -37,7 +38,7 @@ import static org.junit.Assert.fail;
|
||||||
* @author Andrea Boriero
|
* @author Andrea Boriero
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-9286")
|
@TestForIssue(jiraKey = "HHH-9286")
|
||||||
@RequiresDialect(Oracle10gDialect.class)
|
@RequiresDialect(OracleDialect.class)
|
||||||
public class StoreProcedureRefCursorOutParameterByNameTest extends BaseEntityManagerFunctionalTestCase {
|
public class StoreProcedureRefCursorOutParameterByNameTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
EntityManagerFactory entityManagerFactory;
|
EntityManagerFactory entityManagerFactory;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.jpa.procedure;
|
package org.hibernate.orm.test.jpa.procedure;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -21,6 +21,7 @@ import jakarta.persistence.StoredProcedureQuery;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.dialect.Oracle10gDialect;
|
import org.hibernate.dialect.Oracle10gDialect;
|
||||||
|
import org.hibernate.dialect.OracleDialect;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
@ -37,7 +38,7 @@ import static org.junit.Assert.fail;
|
||||||
* @author Andrea Boriero
|
* @author Andrea Boriero
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-9286")
|
@TestForIssue(jiraKey = "HHH-9286")
|
||||||
@RequiresDialect(Oracle10gDialect.class)
|
@RequiresDialect(OracleDialect.class)
|
||||||
public class StoreProcedureRefCursorOutParameterByPositionTest extends BaseEntityManagerFunctionalTestCase {
|
public class StoreProcedureRefCursorOutParameterByPositionTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
EntityManagerFactory entityManagerFactory;
|
EntityManagerFactory entityManagerFactory;
|
||||||
|
|
|
@ -0,0 +1,278 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* 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.bootstrap.binding.annotations.access.jpa;
|
||||||
|
|
||||||
|
import org.hibernate.MappingException;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
import org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Animal;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Being;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course1;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course2;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course3;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course4;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course5;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course6;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course7;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course8;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Horse;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Person;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Student;
|
||||||
|
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.User;
|
||||||
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
import org.hibernate.property.access.spi.GetterFieldImpl;
|
||||||
|
import org.hibernate.property.access.spi.GetterMethodImpl;
|
||||||
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests verifying the correct behaviour for the usage of {@code @jakarta.persistence.Access}.
|
||||||
|
*
|
||||||
|
* @author Hardy Ferentschik
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "deprecation" })
|
||||||
|
public class AccessMappingTest {
|
||||||
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
if ( serviceRegistry != null ) {
|
||||||
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInconsistentAnnotationPlacement() {
|
||||||
|
Configuration cfg = new Configuration();
|
||||||
|
cfg.addAnnotatedClass( Course1.class );
|
||||||
|
cfg.addAnnotatedClass( Student.class );
|
||||||
|
SessionFactory sf = null;
|
||||||
|
try {
|
||||||
|
sf = cfg.buildSessionFactory( serviceRegistry );
|
||||||
|
fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
|
||||||
|
}
|
||||||
|
catch (MappingException e) {
|
||||||
|
// success
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if ( sf != null ) {
|
||||||
|
sf.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFieldAnnotationPlacement() {
|
||||||
|
Configuration cfg = new Configuration();
|
||||||
|
Class<?> classUnderTest = Course6.class;
|
||||||
|
cfg.addAnnotatedClass( classUnderTest );
|
||||||
|
cfg.addAnnotatedClass( Student.class );
|
||||||
|
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||||
|
try {
|
||||||
|
final EntityPersister entityPersister = factory.getEntityPersister( classUnderTest.getName() );
|
||||||
|
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"Field access should be used.",
|
||||||
|
identifierMapping.getPropertyAccess().getGetter() instanceof GetterFieldImpl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
factory.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPropertyAnnotationPlacement() {
|
||||||
|
Configuration cfg = new Configuration();
|
||||||
|
Class<?> classUnderTest = Course7.class;
|
||||||
|
cfg.addAnnotatedClass( classUnderTest );
|
||||||
|
cfg.addAnnotatedClass( Student.class );
|
||||||
|
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||||
|
try {
|
||||||
|
final EntityPersister entityPersister = factory.getEntityPersister( classUnderTest.getName() );
|
||||||
|
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"Property access should be used.",
|
||||||
|
identifierMapping.getPropertyAccess().getGetter() instanceof GetterMethodImpl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
factory.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExplicitPropertyAccessAnnotationsOnProperty() throws Exception {
|
||||||
|
Configuration cfg = new Configuration();
|
||||||
|
Class<?> classUnderTest = Course2.class;
|
||||||
|
cfg.addAnnotatedClass( classUnderTest );
|
||||||
|
cfg.addAnnotatedClass( Student.class );
|
||||||
|
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||||
|
try {
|
||||||
|
final EntityPersister entityPersister = factory.getEntityPersister( classUnderTest.getName() );
|
||||||
|
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"Property access should be used.",
|
||||||
|
identifierMapping.getPropertyAccess().getGetter() instanceof GetterMethodImpl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
factory.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExplicitPropertyAccessAnnotationsOnField() {
|
||||||
|
Configuration cfg = new Configuration();
|
||||||
|
cfg.addAnnotatedClass( Course4.class );
|
||||||
|
cfg.addAnnotatedClass( Student.class );
|
||||||
|
SessionFactory sf = null;
|
||||||
|
try {
|
||||||
|
sf = cfg.buildSessionFactory( serviceRegistry );
|
||||||
|
fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
|
||||||
|
}
|
||||||
|
catch (MappingException e) {
|
||||||
|
// success
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if ( sf != null ) {
|
||||||
|
sf.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExplicitPropertyAccessAnnotationsWithHibernateStyleOverride() {
|
||||||
|
Configuration cfg = new Configuration();
|
||||||
|
Class<?> classUnderTest = Course3.class;
|
||||||
|
cfg.addAnnotatedClass( classUnderTest );
|
||||||
|
cfg.addAnnotatedClass( Student.class );
|
||||||
|
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||||
|
try {
|
||||||
|
final EntityPersister entityPersister = factory.getEntityPersister( classUnderTest.getName() );
|
||||||
|
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"Field access should be used.",
|
||||||
|
identifierMapping.getPropertyAccess().getGetter() instanceof GetterFieldImpl
|
||||||
|
);
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"Property access should be used.",
|
||||||
|
entityPersister.getAttributeMapping( 0 ).getPropertyAccess().getGetter() instanceof GetterMethodImpl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
factory.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExplicitPropertyAccessAnnotationsWithJpaStyleOverride() {
|
||||||
|
Configuration cfg = new Configuration();
|
||||||
|
Class<?> classUnderTest = Course5.class;
|
||||||
|
cfg.addAnnotatedClass( classUnderTest );
|
||||||
|
cfg.addAnnotatedClass( Student.class );
|
||||||
|
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||||
|
try {
|
||||||
|
final EntityPersister entityPersister = factory.getEntityPersister( classUnderTest.getName() );
|
||||||
|
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"Field access should be used.",
|
||||||
|
identifierMapping.getPropertyAccess().getGetter() instanceof GetterFieldImpl
|
||||||
|
);
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"Property access should be used.",
|
||||||
|
entityPersister.getAttributeMapping( 0 ).getPropertyAccess().getGetter() instanceof GetterMethodImpl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
factory.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDefaultFieldAccessIsInherited() {
|
||||||
|
Configuration cfg = new Configuration();
|
||||||
|
Class<?> classUnderTest = User.class;
|
||||||
|
cfg.addAnnotatedClass( classUnderTest );
|
||||||
|
cfg.addAnnotatedClass( Person.class );
|
||||||
|
cfg.addAnnotatedClass( Being.class );
|
||||||
|
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||||
|
try {
|
||||||
|
final EntityPersister entityPersister = factory.getEntityPersister( classUnderTest.getName() );
|
||||||
|
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"Field access should be used since the default access mode gets inherited",
|
||||||
|
identifierMapping.getPropertyAccess().getGetter() instanceof GetterFieldImpl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
factory.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDefaultPropertyAccessIsInherited() {
|
||||||
|
Configuration cfg = new Configuration();
|
||||||
|
cfg.addAnnotatedClass( Horse.class );
|
||||||
|
cfg.addAnnotatedClass( Animal.class );
|
||||||
|
|
||||||
|
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||||
|
try {
|
||||||
|
EntityPersister entityPersister = factory.getEntityPersister( Animal.class.getName() );
|
||||||
|
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"Property access should be used since explicity configured via @Access",
|
||||||
|
identifierMapping.getPropertyAccess().getGetter() instanceof GetterMethodImpl
|
||||||
|
);
|
||||||
|
|
||||||
|
entityPersister = factory.getEntityPersister( Horse.class.getName() );
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"Field access should be used since the default access mode gets inherited",
|
||||||
|
entityPersister.getAttributeMapping( 0 ).getPropertyAccess().getGetter() instanceof GetterFieldImpl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
factory.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestForIssue(jiraKey = "HHH-5004")
|
||||||
|
@Test
|
||||||
|
public void testAccessOnClassAndId() {
|
||||||
|
Configuration cfg = new Configuration();
|
||||||
|
cfg.addAnnotatedClass( Course8.class );
|
||||||
|
cfg.addAnnotatedClass( Student.class );
|
||||||
|
cfg.buildSessionFactory( serviceRegistry ).close();
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.dialect.Oracle10gDialect;
|
import org.hibernate.dialect.Oracle10gDialect;
|
||||||
|
import org.hibernate.dialect.OracleDialect;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
@ -41,7 +42,7 @@ import static org.junit.Assert.fail;
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-10761")
|
@TestForIssue(jiraKey = "HHH-10761")
|
||||||
@RequiresDialect(Oracle10gDialect.class)
|
@RequiresDialect(OracleDialect.class)
|
||||||
public class StoredProcedureNullParameterByNameTest extends BaseEntityManagerFunctionalTestCase {
|
public class StoredProcedureNullParameterByNameTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
EntityManagerFactory entityManagerFactory;
|
EntityManagerFactory entityManagerFactory;
|
||||||
|
|
||||||
|
@ -50,6 +51,12 @@ public class StoredProcedureNullParameterByNameTest extends BaseEntityManagerFun
|
||||||
return new Class[] {User.class};
|
return new Class[] {User.class};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// @SuppressWarnings({ "unchecked" })
|
||||||
|
// protected void addConfigOptions(Map options) {
|
||||||
|
// options.put( org.hibernate.cfg.AvailableSettings.PROCEDURE_NULL_PARAM_PASSING, "true" );
|
||||||
|
// }
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void startUp() {
|
public void startUp() {
|
||||||
entityManagerFactory = getOrCreateEntityManager().getEntityManagerFactory();
|
entityManagerFactory = getOrCreateEntityManager().getEntityManagerFactory();
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* 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.jpa.test.criteria.paths;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
|
||||||
import jakarta.persistence.criteria.JoinType;
|
|
||||||
import jakarta.persistence.metamodel.Attribute;
|
|
||||||
import jakarta.persistence.metamodel.Bindable;
|
|
||||||
import jakarta.persistence.metamodel.SingularAttribute;
|
|
||||||
import jakarta.persistence.metamodel.Type;
|
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
import static org.mockito.Mockito.withSettings;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Andrea Boriero
|
|
||||||
*/
|
|
||||||
public class EntityModeMapJoinsTest extends BaseEntityManagerFunctionalTestCase {
|
|
||||||
@Override
|
|
||||||
protected String[] getMappings() {
|
|
||||||
return new String[] {
|
|
||||||
getClass().getPackage().getName().replace( '.', '/' ) + "/PolicyAndDistribution.hbm.xml"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addConfigOptions(Map options) {
|
|
||||||
super.addConfigOptions( options );
|
|
||||||
|
|
||||||
// make sure that dynamic-map mode entity types are returned in the metamodel.
|
|
||||||
options.put( AvailableSettings.JPA_METAMODEL_POPULATION, "enabled" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When building a join from a non-class based entity (EntityMode.MAP), make sure you get the Bindable from
|
|
||||||
* the SingularAttribute as the join model. If you don't, you'll get the first non-classed based entity
|
|
||||||
* you added to your configuration. Regression for HHH-9142.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testEntityModeMapJoins() throws Exception {
|
|
||||||
CriteriaBuilder criteriaBuilder = mock( CriteriaBuilder.class);
|
|
||||||
PathSource pathSource = mock( PathSource.class);
|
|
||||||
SingularAttribute joinAttribute = mock( SingularAttribute.class);
|
|
||||||
when(joinAttribute.getPersistentAttributeType()).thenReturn( Attribute.PersistentAttributeType.MANY_TO_ONE);
|
|
||||||
Type joinType = mock( Type.class, withSettings().extraInterfaces( Bindable.class));
|
|
||||||
when(joinAttribute.getType()).thenReturn(joinType);
|
|
||||||
SingularAttributeJoin join = new SingularAttributeJoin( criteriaBuilder, null, pathSource, joinAttribute, JoinType.LEFT);
|
|
||||||
|
|
||||||
assertEquals( joinType, join.getModel());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,264 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* 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.annotations.access.jpa;
|
|
||||||
|
|
||||||
import org.hibernate.MappingException;
|
|
||||||
import org.hibernate.SessionFactory;
|
|
||||||
import org.hibernate.cfg.Configuration;
|
|
||||||
import org.hibernate.cfg.Environment;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|
||||||
import org.hibernate.property.access.spi.GetterFieldImpl;
|
|
||||||
import org.hibernate.property.access.spi.GetterMethodImpl;
|
|
||||||
import org.hibernate.service.ServiceRegistry;
|
|
||||||
import org.hibernate.tuple.entity.EntityTuplizer;
|
|
||||||
|
|
||||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests verifying the correct behaviour for the usage of {@code @jakarta.persistence.Access}.
|
|
||||||
*
|
|
||||||
* @author Hardy Ferentschik
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({ "deprecation" })
|
|
||||||
public class AccessMappingTest {
|
|
||||||
private ServiceRegistry serviceRegistry;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
if ( serviceRegistry != null ) {
|
|
||||||
ServiceRegistryBuilder.destroy( serviceRegistry );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testInconsistentAnnotationPlacement() throws Exception {
|
|
||||||
Configuration cfg = new Configuration();
|
|
||||||
cfg.addAnnotatedClass( Course1.class );
|
|
||||||
cfg.addAnnotatedClass( Student.class );
|
|
||||||
SessionFactory sf = null;
|
|
||||||
try {
|
|
||||||
sf = cfg.buildSessionFactory( serviceRegistry );
|
|
||||||
fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
|
|
||||||
}
|
|
||||||
catch (MappingException e) {
|
|
||||||
// success
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
if ( sf != null ) {
|
|
||||||
sf.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFieldAnnotationPlacement() throws Exception {
|
|
||||||
Configuration cfg = new Configuration();
|
|
||||||
Class<?> classUnderTest = Course6.class;
|
|
||||||
cfg.addAnnotatedClass( classUnderTest );
|
|
||||||
cfg.addAnnotatedClass( Student.class );
|
|
||||||
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
|
||||||
try {
|
|
||||||
EntityTuplizer tuplizer = factory.getEntityPersister( classUnderTest.getName() )
|
|
||||||
.getEntityMetamodel()
|
|
||||||
.getTuplizer();
|
|
||||||
assertTrue(
|
|
||||||
"Field access should be used.",
|
|
||||||
tuplizer.getIdentifierGetter() instanceof GetterFieldImpl
|
|
||||||
);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
factory.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPropertyAnnotationPlacement() throws Exception {
|
|
||||||
Configuration cfg = new Configuration();
|
|
||||||
Class<?> classUnderTest = Course7.class;
|
|
||||||
cfg.addAnnotatedClass( classUnderTest );
|
|
||||||
cfg.addAnnotatedClass( Student.class );
|
|
||||||
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
|
||||||
try {
|
|
||||||
EntityTuplizer tuplizer = factory.getEntityPersister( classUnderTest.getName() )
|
|
||||||
.getEntityMetamodel()
|
|
||||||
.getTuplizer();
|
|
||||||
assertTrue(
|
|
||||||
"Property access should be used.",
|
|
||||||
tuplizer.getIdentifierGetter() instanceof GetterMethodImpl
|
|
||||||
);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
factory.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExplicitPropertyAccessAnnotationsOnProperty() throws Exception {
|
|
||||||
Configuration cfg = new Configuration();
|
|
||||||
Class<?> classUnderTest = Course2.class;
|
|
||||||
cfg.addAnnotatedClass( classUnderTest );
|
|
||||||
cfg.addAnnotatedClass( Student.class );
|
|
||||||
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
|
||||||
try {
|
|
||||||
EntityTuplizer tuplizer = factory.getEntityPersister( classUnderTest.getName() )
|
|
||||||
.getEntityMetamodel()
|
|
||||||
.getTuplizer();
|
|
||||||
assertTrue(
|
|
||||||
"Property access should be used.",
|
|
||||||
tuplizer.getIdentifierGetter() instanceof GetterMethodImpl
|
|
||||||
);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
factory.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExplicitPropertyAccessAnnotationsOnField() throws Exception {
|
|
||||||
Configuration cfg = new Configuration();
|
|
||||||
cfg.addAnnotatedClass( Course4.class );
|
|
||||||
cfg.addAnnotatedClass( Student.class );
|
|
||||||
SessionFactory sf= null;
|
|
||||||
try {
|
|
||||||
sf = cfg.buildSessionFactory( serviceRegistry );
|
|
||||||
fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
|
|
||||||
}
|
|
||||||
catch (MappingException e) {
|
|
||||||
// success
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
if ( sf != null ) {
|
|
||||||
sf.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExplicitPropertyAccessAnnotationsWithHibernateStyleOverride() throws Exception {
|
|
||||||
Configuration cfg = new Configuration();
|
|
||||||
Class<?> classUnderTest = Course3.class;
|
|
||||||
cfg.addAnnotatedClass( classUnderTest );
|
|
||||||
cfg.addAnnotatedClass( Student.class );
|
|
||||||
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
|
||||||
try {
|
|
||||||
EntityTuplizer tuplizer = factory.getEntityPersister( classUnderTest.getName() )
|
|
||||||
.getEntityMetamodel()
|
|
||||||
.getTuplizer();
|
|
||||||
assertTrue(
|
|
||||||
"Field access should be used.",
|
|
||||||
tuplizer.getIdentifierGetter() instanceof GetterFieldImpl
|
|
||||||
);
|
|
||||||
|
|
||||||
assertTrue(
|
|
||||||
"Property access should be used.",
|
|
||||||
tuplizer.getGetter( 0 ) instanceof GetterMethodImpl
|
|
||||||
);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
factory.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExplicitPropertyAccessAnnotationsWithJpaStyleOverride() throws Exception {
|
|
||||||
Configuration cfg = new Configuration();
|
|
||||||
Class<?> classUnderTest = Course5.class;
|
|
||||||
cfg.addAnnotatedClass( classUnderTest );
|
|
||||||
cfg.addAnnotatedClass( Student.class );
|
|
||||||
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
|
||||||
try {
|
|
||||||
EntityTuplizer tuplizer = factory.getEntityPersister( classUnderTest.getName() )
|
|
||||||
.getEntityMetamodel()
|
|
||||||
.getTuplizer();
|
|
||||||
assertTrue(
|
|
||||||
"Field access should be used.",
|
|
||||||
tuplizer.getIdentifierGetter() instanceof GetterFieldImpl
|
|
||||||
);
|
|
||||||
|
|
||||||
assertTrue(
|
|
||||||
"Property access should be used.",
|
|
||||||
tuplizer.getGetter( 0 ) instanceof GetterMethodImpl
|
|
||||||
);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
factory.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDefaultFieldAccessIsInherited() throws Exception {
|
|
||||||
Configuration cfg = new Configuration();
|
|
||||||
Class<?> classUnderTest = User.class;
|
|
||||||
cfg.addAnnotatedClass( classUnderTest );
|
|
||||||
cfg.addAnnotatedClass( Person.class );
|
|
||||||
cfg.addAnnotatedClass( Being.class );
|
|
||||||
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
|
||||||
try {
|
|
||||||
EntityTuplizer tuplizer = factory.getEntityPersister( classUnderTest.getName() )
|
|
||||||
.getEntityMetamodel()
|
|
||||||
.getTuplizer();
|
|
||||||
assertTrue(
|
|
||||||
"Field access should be used since the default access mode gets inherited",
|
|
||||||
tuplizer.getIdentifierGetter() instanceof GetterFieldImpl
|
|
||||||
);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
factory.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDefaultPropertyAccessIsInherited() throws Exception {
|
|
||||||
Configuration cfg = new Configuration();
|
|
||||||
cfg.addAnnotatedClass( Horse.class );
|
|
||||||
cfg.addAnnotatedClass( Animal.class );
|
|
||||||
|
|
||||||
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
|
||||||
try {
|
|
||||||
EntityTuplizer tuplizer = factory.getEntityPersister( Animal.class.getName() )
|
|
||||||
.getEntityMetamodel()
|
|
||||||
.getTuplizer();
|
|
||||||
assertTrue(
|
|
||||||
"Property access should be used since explicity configured via @Access",
|
|
||||||
tuplizer.getIdentifierGetter() instanceof GetterMethodImpl
|
|
||||||
);
|
|
||||||
|
|
||||||
tuplizer = factory.getEntityPersister( Horse.class.getName() )
|
|
||||||
.getEntityMetamodel()
|
|
||||||
.getTuplizer();
|
|
||||||
assertTrue(
|
|
||||||
"Field access should be used since the default access mode gets inherited",
|
|
||||||
tuplizer.getGetter( 0 ) instanceof GetterFieldImpl
|
|
||||||
);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
factory.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestForIssue(jiraKey = "HHH-5004")
|
|
||||||
@Test
|
|
||||||
public void testAccessOnClassAndId() throws Exception {
|
|
||||||
Configuration cfg = new Configuration();
|
|
||||||
cfg.addAnnotatedClass( Course8.class );
|
|
||||||
cfg.addAnnotatedClass( Student.class );
|
|
||||||
cfg.buildSessionFactory( serviceRegistry ).close();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue