Fix IdentifiableType#getId(Class<Y> type) failing for primitive types
This commit is contained in:
parent
37d3b66ce4
commit
c959c7656c
|
@ -22,6 +22,7 @@ import org.hibernate.metamodel.model.domain.internal.EmbeddedSqmPathSource;
|
|||
import org.hibernate.metamodel.model.domain.internal.NonAggregatedCompositeSqmPathSource;
|
||||
import org.hibernate.query.sqm.SqmPathSource;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.descriptor.java.spi.PrimitiveJavaType;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
|
@ -142,16 +143,19 @@ public abstract class AbstractIdentifiableType<J>
|
|||
}
|
||||
|
||||
private void checkType(SingularPersistentAttribute<?, ?> attribute, Class<?> javaType) {
|
||||
if ( ! javaType.isAssignableFrom( attribute.getType().getJavaType() ) ) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"Attribute [%s#%s : %s] not castable to requested type [%s]",
|
||||
getTypeName(),
|
||||
attribute.getName(),
|
||||
attribute.getType().getJavaType().getName(),
|
||||
javaType.getName()
|
||||
)
|
||||
);
|
||||
if ( !javaType.isAssignableFrom( attribute.getType().getJavaType() ) ) {
|
||||
final JavaType<?> attributeJavaTypeDescriptor = attribute.getAttributeJavaTypeDescriptor();
|
||||
if ( !( attributeJavaTypeDescriptor instanceof PrimitiveJavaType ) || ( (PrimitiveJavaType) attributeJavaTypeDescriptor ).getPrimitiveClass() != javaType ) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"Attribute [%s#%s : %s] not castable to requested type [%s]",
|
||||
getTypeName(),
|
||||
attribute.getName(),
|
||||
attribute.getType().getJavaType().getName(),
|
||||
javaType.getName()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,71 +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.metamodel;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.metamodel.EntityType;
|
||||
import jakarta.persistence.metamodel.ManagedType;
|
||||
import jakarta.persistence.metamodel.SingularAttribute;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class EmbeddedTypeTest extends BaseEntityManagerFunctionalTestCase {
|
||||
@Override
|
||||
public Class[] getAnnotatedClasses() {
|
||||
return new Class[] {
|
||||
Product.class, ShelfLife.class, VersionedEntity.class
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-6896" )
|
||||
public void ensureComponentsReturnedAsManagedType() {
|
||||
ManagedType<ShelfLife> managedType = entityManagerFactory().getMetamodel().managedType( ShelfLife.class );
|
||||
// the issue was in regards to throwing an exception, but also check for nullness
|
||||
assertNotNull( managedType );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-4702" )
|
||||
public void testSingularAttributeAccessByName() {
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
|
||||
SingularAttribute soldDate_ = em.getMetamodel().embeddable( ShelfLife.class )
|
||||
.getSingularAttribute( "soldDate" );
|
||||
assertEquals( java.sql.Date.class, soldDate_.getBindableJavaType());
|
||||
assertEquals( java.sql.Date.class, soldDate_.getType().getJavaType() );
|
||||
assertEquals( java.sql.Date.class, soldDate_.getJavaType() );
|
||||
|
||||
em.getTransaction().commit();
|
||||
em.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-5821" )
|
||||
public void testVersionAttributeMetadata() {
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
EntityType<VersionedEntity> metadata = em.getMetamodel().entity( VersionedEntity.class );
|
||||
assertNotNull( metadata.getDeclaredVersion( int.class ) );
|
||||
assertTrue( metadata.getDeclaredVersion( int.class ).isVersion() );
|
||||
assertEquals( 3, metadata.getDeclaredSingularAttributes().size() );
|
||||
assertTrue( metadata.getDeclaredSingularAttributes().contains( metadata.getDeclaredVersion( int.class ) ) );
|
||||
em.close();
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.jpa.test.metamodel;
|
||||
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractJpaMetamodelPopulationTest;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.jpa.test.metamodel;
|
||||
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractJpaMetamodelPopulationTest;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.jpa.test.metamodel;
|
||||
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractJpaMetamodelPopulationTest;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,24 +6,24 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.jpa.criteria;
|
||||
|
||||
import org.hibernate.jpa.test.metamodel.Address;
|
||||
import org.hibernate.jpa.test.metamodel.Alias;
|
||||
import org.hibernate.jpa.test.metamodel.Country;
|
||||
import org.hibernate.jpa.test.metamodel.CreditCard;
|
||||
import org.hibernate.jpa.test.metamodel.Customer;
|
||||
import org.hibernate.jpa.test.metamodel.Entity1;
|
||||
import org.hibernate.jpa.test.metamodel.Entity2;
|
||||
import org.hibernate.jpa.test.metamodel.Entity3;
|
||||
import org.hibernate.jpa.test.metamodel.Info;
|
||||
import org.hibernate.jpa.test.metamodel.LineItem;
|
||||
import org.hibernate.jpa.test.metamodel.Order;
|
||||
import org.hibernate.jpa.test.metamodel.Phone;
|
||||
import org.hibernate.jpa.test.metamodel.Product;
|
||||
import org.hibernate.jpa.test.metamodel.ShelfLife;
|
||||
import org.hibernate.jpa.test.metamodel.Spouse;
|
||||
import org.hibernate.jpa.test.metamodel.Thing;
|
||||
import org.hibernate.jpa.test.metamodel.ThingWithQuantity;
|
||||
import org.hibernate.jpa.test.metamodel.VersionedEntity;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Address;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Alias;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Country;
|
||||
import org.hibernate.orm.test.jpa.metamodel.CreditCard;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Entity1;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Entity2;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Entity3;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Info;
|
||||
import org.hibernate.orm.test.jpa.metamodel.LineItem;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Order;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Phone;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Product;
|
||||
import org.hibernate.orm.test.jpa.metamodel.ShelfLife;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Spouse;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Thing;
|
||||
import org.hibernate.orm.test.jpa.metamodel.ThingWithQuantity;
|
||||
import org.hibernate.orm.test.jpa.metamodel.VersionedEntity;
|
||||
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
|
||||
|
|
|
@ -29,18 +29,18 @@ import org.hibernate.orm.test.jpa.callbacks.Television;
|
|||
import org.hibernate.orm.test.jpa.callbacks.VideoSystem;
|
||||
import org.hibernate.orm.test.jpa.inheritance.Fruit;
|
||||
import org.hibernate.orm.test.jpa.inheritance.Strawberry;
|
||||
import org.hibernate.jpa.test.metamodel.Address;
|
||||
import org.hibernate.jpa.test.metamodel.Alias;
|
||||
import org.hibernate.jpa.test.metamodel.Country;
|
||||
import org.hibernate.jpa.test.metamodel.CreditCard;
|
||||
import org.hibernate.jpa.test.metamodel.Customer;
|
||||
import org.hibernate.jpa.test.metamodel.Info;
|
||||
import org.hibernate.jpa.test.metamodel.LineItem;
|
||||
import org.hibernate.jpa.test.metamodel.Order;
|
||||
import org.hibernate.jpa.test.metamodel.Phone;
|
||||
import org.hibernate.jpa.test.metamodel.Product;
|
||||
import org.hibernate.jpa.test.metamodel.ShelfLife;
|
||||
import org.hibernate.jpa.test.metamodel.Spouse;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Address;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Alias;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Country;
|
||||
import org.hibernate.orm.test.jpa.metamodel.CreditCard;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Info;
|
||||
import org.hibernate.orm.test.jpa.metamodel.LineItem;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Order;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Phone;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Product;
|
||||
import org.hibernate.orm.test.jpa.metamodel.ShelfLife;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Spouse;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.transaction.TransactionUtil;
|
||||
|
|
|
@ -15,9 +15,9 @@ import jakarta.persistence.criteria.Root;
|
|||
import jakarta.persistence.criteria.Subquery;
|
||||
|
||||
import org.hibernate.dialect.MySQLDialect;
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.jpa.test.metamodel.Customer;
|
||||
import org.hibernate.jpa.test.metamodel.Customer_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer_;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ import jakarta.persistence.criteria.CollectionJoin;
|
|||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.jpa.test.metamodel.LineItem;
|
||||
import org.hibernate.jpa.test.metamodel.LineItem_;
|
||||
import org.hibernate.jpa.test.metamodel.Order;
|
||||
import org.hibernate.jpa.test.metamodel.Order_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.LineItem;
|
||||
import org.hibernate.orm.test.jpa.metamodel.LineItem_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Order;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Order_;
|
||||
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -22,19 +22,19 @@ import jakarta.persistence.criteria.SetJoin;
|
|||
import jakarta.persistence.metamodel.EntityType;
|
||||
import org.hibernate.dialect.CockroachDialect;
|
||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.jpa.test.metamodel.Address;
|
||||
import org.hibernate.jpa.test.metamodel.Alias;
|
||||
import org.hibernate.jpa.test.metamodel.Country;
|
||||
import org.hibernate.jpa.test.metamodel.CreditCard;
|
||||
import org.hibernate.jpa.test.metamodel.Customer;
|
||||
import org.hibernate.jpa.test.metamodel.Customer_;
|
||||
import org.hibernate.jpa.test.metamodel.Info;
|
||||
import org.hibernate.jpa.test.metamodel.LineItem;
|
||||
import org.hibernate.jpa.test.metamodel.Order;
|
||||
import org.hibernate.jpa.test.metamodel.Phone;
|
||||
import org.hibernate.jpa.test.metamodel.Product;
|
||||
import org.hibernate.jpa.test.metamodel.ShelfLife;
|
||||
import org.hibernate.jpa.test.metamodel.Spouse;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Address;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Alias;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Country;
|
||||
import org.hibernate.orm.test.jpa.metamodel.CreditCard;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Info;
|
||||
import org.hibernate.orm.test.jpa.metamodel.LineItem;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Order;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Phone;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Product;
|
||||
import org.hibernate.orm.test.jpa.metamodel.ShelfLife;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Spouse;
|
||||
import org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl;
|
||||
import org.hibernate.query.sqm.tree.predicate.SqmComparisonPredicate;
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ import jakarta.persistence.criteria.Root;
|
|||
import jakarta.persistence.metamodel.EntityType;
|
||||
|
||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.jpa.test.metamodel.Thing;
|
||||
import org.hibernate.jpa.test.metamodel.ThingWithQuantity;
|
||||
import org.hibernate.jpa.test.metamodel.ThingWithQuantity_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Thing;
|
||||
import org.hibernate.orm.test.jpa.metamodel.ThingWithQuantity;
|
||||
import org.hibernate.orm.test.jpa.metamodel.ThingWithQuantity_;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -13,9 +13,9 @@ import jakarta.persistence.criteria.CriteriaBuilder;
|
|||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.jpa.test.metamodel.Product;
|
||||
import org.hibernate.jpa.test.metamodel.Product_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Product;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Product_;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
|
@ -14,8 +14,8 @@ import jakarta.persistence.criteria.CriteriaQuery;
|
|||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.dialect.DerbyDialect;
|
||||
import org.hibernate.jpa.test.metamodel.Product;
|
||||
import org.hibernate.jpa.test.metamodel.Product_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Product;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Product_;
|
||||
import org.hibernate.orm.test.jpa.criteria.AbstractCriteriaTest;
|
||||
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
|
|
|
@ -21,10 +21,10 @@ import jakarta.persistence.criteria.Root;
|
|||
import org.hibernate.dialect.DB2Dialect;
|
||||
import org.hibernate.dialect.DerbyDialect;
|
||||
import org.hibernate.query.Query;
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.jpa.test.metamodel.Phone;
|
||||
import org.hibernate.jpa.test.metamodel.Product;
|
||||
import org.hibernate.jpa.test.metamodel.Product_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Phone;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Product;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Product_;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||
|
|
|
@ -14,10 +14,10 @@ import jakarta.persistence.criteria.CriteriaQuery;
|
|||
import jakarta.persistence.criteria.ListJoin;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.jpa.test.metamodel.Address;
|
||||
import org.hibernate.jpa.test.metamodel.Address_;
|
||||
import org.hibernate.jpa.test.metamodel.Phone;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Address;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Address_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Phone;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
|
|
@ -16,12 +16,12 @@ import jakarta.persistence.criteria.Root;
|
|||
|
||||
import org.hibernate.dialect.CockroachDialect;
|
||||
import org.hibernate.dialect.OracleDialect;
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.jpa.test.metamodel.CreditCard;
|
||||
import org.hibernate.jpa.test.metamodel.CreditCard_;
|
||||
import org.hibernate.jpa.test.metamodel.Customer_;
|
||||
import org.hibernate.jpa.test.metamodel.Order;
|
||||
import org.hibernate.jpa.test.metamodel.Order_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.CreditCard;
|
||||
import org.hibernate.orm.test.jpa.metamodel.CreditCard_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Order;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Order_;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.junit.jupiter.api.Assertions;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
|
||||
/**
|
||||
* @author Erich Heard
|
||||
|
|
|
@ -12,11 +12,11 @@ import jakarta.persistence.criteria.CriteriaQuery;
|
|||
import jakarta.persistence.criteria.MapJoin;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.jpa.test.metamodel.MapEntity;
|
||||
import org.hibernate.jpa.test.metamodel.MapEntityLocal;
|
||||
import org.hibernate.jpa.test.metamodel.MapEntityLocal_;
|
||||
import org.hibernate.jpa.test.metamodel.MapEntity_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.MapEntity;
|
||||
import org.hibernate.orm.test.jpa.metamodel.MapEntityLocal;
|
||||
import org.hibernate.orm.test.jpa.metamodel.MapEntityLocal_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.MapEntity_;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ import jakarta.persistence.criteria.CriteriaQuery;
|
|||
import jakarta.persistence.criteria.Path;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.jpa.test.metamodel.Order;
|
||||
import org.hibernate.jpa.test.metamodel.Thing;
|
||||
import org.hibernate.jpa.test.metamodel.ThingWithQuantity;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Order;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Thing;
|
||||
import org.hibernate.orm.test.jpa.metamodel.ThingWithQuantity;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ExpectedException;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
|
|
@ -31,11 +31,11 @@ import jakarta.persistence.criteria.Join;
|
|||
import jakarta.persistence.criteria.JoinType;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.jpa.test.metamodel.Entity1;
|
||||
import org.hibernate.jpa.test.metamodel.Entity1_;
|
||||
import org.hibernate.jpa.test.metamodel.Entity2;
|
||||
import org.hibernate.jpa.test.metamodel.Entity2_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Entity1;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Entity1_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Entity2;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Entity2_;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
|
@ -12,15 +12,15 @@ import java.util.List;
|
|||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.jpa.test.metamodel.Address;
|
||||
import org.hibernate.jpa.test.metamodel.Address_;
|
||||
import org.hibernate.jpa.test.metamodel.Article;
|
||||
import org.hibernate.jpa.test.metamodel.Article_;
|
||||
import org.hibernate.jpa.test.metamodel.MapEntity;
|
||||
import org.hibernate.jpa.test.metamodel.MapEntityLocal;
|
||||
import org.hibernate.jpa.test.metamodel.MapEntity_;
|
||||
import org.hibernate.jpa.test.metamodel.Translation;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Address;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Address_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Article;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Article_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.MapEntity;
|
||||
import org.hibernate.orm.test.jpa.metamodel.MapEntityLocal;
|
||||
import org.hibernate.orm.test.jpa.metamodel.MapEntity_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Translation;
|
||||
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
|
||||
import org.hibernate.query.criteria.JpaExpression;
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ import jakarta.persistence.criteria.Root;
|
|||
import jakarta.persistence.criteria.Subquery;
|
||||
|
||||
import org.hibernate.dialect.SybaseASEDialect;
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.jpa.test.metamodel.Customer;
|
||||
import org.hibernate.jpa.test.metamodel.Customer_;
|
||||
import org.hibernate.jpa.test.metamodel.LineItem;
|
||||
import org.hibernate.jpa.test.metamodel.LineItem_;
|
||||
import org.hibernate.jpa.test.metamodel.Order;
|
||||
import org.hibernate.jpa.test.metamodel.Order_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.LineItem;
|
||||
import org.hibernate.orm.test.jpa.metamodel.LineItem_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Order;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Order_;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||
|
|
|
@ -13,11 +13,11 @@ import jakarta.persistence.criteria.Join;
|
|||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.persistence.criteria.Subquery;
|
||||
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.jpa.test.metamodel.Customer;
|
||||
import org.hibernate.jpa.test.metamodel.Customer_;
|
||||
import org.hibernate.jpa.test.metamodel.Order;
|
||||
import org.hibernate.jpa.test.metamodel.Order_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Order;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Order_;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ import jakarta.persistence.criteria.CriteriaQuery;
|
|||
import jakarta.persistence.criteria.Path;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.jpa.test.metamodel.Customer;
|
||||
import org.hibernate.jpa.test.metamodel.Customer_;
|
||||
import org.hibernate.orm.test.jpa.metamodel.AbstractMetamodelSpecificTest;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Customer_;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
import java.util.Collection;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
|
@ -5,7 +5,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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import java.io.Serializable;
|
||||
import jakarta.persistence.EmbeddedId;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Embeddable;
|
||||
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
import java.util.Collection;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* 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.orm.test.jpa.metamodel;
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.metamodel.EntityType;
|
||||
import jakarta.persistence.metamodel.ManagedType;
|
||||
import jakarta.persistence.metamodel.SingularAttribute;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Jpa(
|
||||
annotatedClasses = { Product.class, ShelfLife.class, VersionedEntity.class }
|
||||
)
|
||||
public class EmbeddedTypeTest {
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-6896")
|
||||
public void ensureComponentsReturnedAsManagedType(EntityManagerFactoryScope scope) {
|
||||
ManagedType<ShelfLife> managedType = scope.getEntityManagerFactory()
|
||||
.getMetamodel()
|
||||
.managedType( ShelfLife.class );
|
||||
// the issue was in regards to throwing an exception, but also check for nullness
|
||||
assertNotNull( managedType );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-4702")
|
||||
public void testSingularAttributeAccessByName(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
SingularAttribute soldDate_ = entityManager.getMetamodel().embeddable( ShelfLife.class )
|
||||
.getSingularAttribute( "soldDate" );
|
||||
assertEquals( Date.class, soldDate_.getBindableJavaType() );
|
||||
assertEquals( Date.class, soldDate_.getType().getJavaType() );
|
||||
assertEquals( Date.class, soldDate_.getJavaType() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5821")
|
||||
public void testVersionAttributeMetadata(EntityManagerFactoryScope scope) {
|
||||
scope.inEntityManager(
|
||||
entityManager -> {
|
||||
EntityType<VersionedEntity> metadata = entityManager.getMetamodel().entity( VersionedEntity.class );
|
||||
assertNotNull( metadata.getDeclaredVersion( int.class ) );
|
||||
assertTrue( metadata.getDeclaredVersion( int.class ).isVersion() );
|
||||
assertEquals( 3, metadata.getDeclaredSingularAttributes().size() );
|
||||
assertTrue( metadata.getDeclaredSingularAttributes()
|
||||
.contains( metadata.getDeclaredVersion( int.class ) ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embeddable;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
import java.util.Collection;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
|
@ -8,8 +8,6 @@ package org.hibernate.orm.test.jpa.metamodel;
|
|||
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
import org.hibernate.jpa.test.metamodel.BaseEmbeddedEntity;
|
||||
|
||||
/**
|
||||
* @author Christian Beikov
|
||||
*/
|
||||
|
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
import java.util.Set;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ElementCollection;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import jakarta.persistence.AttributeOverride;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
import java.sql.Date;
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Embeddable;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
|
@ -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.jpa.test.metamodel;
|
||||
package org.hibernate.orm.test.jpa.metamodel;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
|
@ -0,0 +1,70 @@
|
|||
package org.hibernate.orm.test.query.criteria;
|
||||
|
||||
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.Test;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DomainModel(
|
||||
annotatedClasses = { RootEntityTypeModelTest.Company.class }
|
||||
)
|
||||
@SessionFactory
|
||||
public class RootEntityTypeModelTest {
|
||||
|
||||
@Test
|
||||
public void test(SessionFactoryScope scope) {
|
||||
scope.inTransaction( ( session ) -> {
|
||||
CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
|
||||
CriteriaQuery<?> criteria = criteriaBuilder.createQuery();
|
||||
Root<Company> root = criteria.from( Company.class );
|
||||
assertThat( root.getModel().getId( int.class ) ).isNotNull();
|
||||
} );
|
||||
}
|
||||
|
||||
@Entity
|
||||
public static class Company {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
@Basic
|
||||
private String name;
|
||||
|
||||
public Company() {
|
||||
}
|
||||
|
||||
public Company(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue