[Hibernate-JIRA] Created: (HHH-3854) Issue with greedy loading of associations (default-lazy=false )
by Amar Singh (JIRA)
Issue with greedy loading of associations (default-lazy=false )
---------------------------------------------------------------
Key: HHH-3854
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3854
Project: Hibernate Core
Issue Type: Bug
Components: envers
Environment: Hibernate - core 3.4.0-SNAPSHOT, Hibernate-envers (from trunk)
Reporter: Amar Singh
Attachments: greedy-loading.zip
I have an Entity GP which has a many to one association to entity CA.
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.envers.test.integration.onetoone.bidirectional" default-lazy="false">
<class name="BidirectionalRefIngPK" table="BIDIRECTIONAL_REFERENCING_ENTITY">
<id name="id" type="long" column="BIDIRECTIONAL_REFERENCING_ID" >
<generator class="native"/>
</id>
<property name="data"/>
<many-to-one name="reference" cascade="save-update" class="BidirectionalRefEdPK" column="BIDIRECTIONAL_REFERENCED_ID"/>
</class>
<class name="BidirectionalRefEdPK" table="BIDIRECTIONAL_REFERENCED_ENTITY">
<id name="longId" type="long" column="BIDIRECTIONAL_REFERENCED_ID">
<generator class="native"/>
</id>
<property name="data"/>
</class>
</hibernate-mapping>
With this when I load a previous version of BidirectionalRefIngPK, the loading mechanism tries to create a proxy for BidirectionalRefEdPK, but in my case lazy is false so an internal call to createProxy will return NULL hence .
This happens in ToOneIdMapper.java in method mapToEntityFromMap around line 82, which then internally calls for AbstractEntityTuplizer.java line 395 for getProxyFactory() ending in NULL pointer exception because proxy factory is null as mine is a greedy loading.
TO REPRODUCE
~~~~~~~~~~~~~
Please find a zipped folder attached. The zipped file has 4 files:
- GreedyLoading.java (actual testng test case)
- BidirectionalRefEdPK.java (Entity 1)
- BidirectionalRefIngPK.java (Entity 2)
- greedyloading.hbm.xml
Please place the three java files in its package (org.hibernate.envers.test.integration.onetoone.bidirectional), couldn't find the right package so created test case accordingly. Put the greedyloading.hbm.xml in src/test/resources.
Now when testng runs GreedyLoading.java you should see NPE.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[Hibernate-JIRA] Created: (HHH-6913) QuerySyntaxException for valid JPQL query using the IN operator
by Luis Fernando Planella Gonzalez (JIRA)
QuerySyntaxException for valid JPQL query using the IN operator
---------------------------------------------------------------
Key: HHH-6913
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6913
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.6.9
Environment: Hibernate 3.6.9, MySQL 5.1
Reporter: Luis Fernando Planella Gonzalez
The following query, which is valid JPQL:
select person
from Person person
where person.id is not null and (person.category is null or person.category in :a1)
Generates the following error:
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: {vector} [select person
from entities.Person person
where person.id is not null and (person.category is null or person.category in :a10_, :a11_)]
The in clause is not correct.
Note that if removing the 'person.id is not null and' part, the query works. Here is the working example:
select person
from Person person
where person.category is null or person.category in :a1
So, the closing parenthesis must be confusing the IN clause handling.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[Hibernate-JIRA] Created: (HHH-6924) Assertion Failure when building metadata of a class with an Identifier inherited from a MappedSuperclass
by Tom Coogan (JIRA)
Assertion Failure when building metadata of a class with an Identifier inherited from a MappedSuperclass
--------------------------------------------------------------------------------------------------------
Key: HHH-6924
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6924
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 4.0.0.Final
Environment: Hibernate Core 4.0.0.Final
Hibernate Commons Annotations 4.0.1.Final
PostgreSQL 9.1.2
Reporter: Tom Coogan
Priority: Critical
Our model classes inherit their identifiers from a MappedSuperclass as follows:
{code}
@MappedSuperclass
public abstract class GenericModel {
protected Long id;
@Id
@GeneratedValue(generator="postgres-seq")
@GenericGenerator(name="postgres-seq", strategy = "com.zzz.zzz.util.PostgresSequenceGenerator")
@Column(name = "id", nullable = false)
public Long getId() { return this.id; }
public void setId(Long id) { this.id = id; }
}
@Entity
@Table(name="users")
public class User extends GenericModel {
...
}
{code}
When building the metadata for these classes, the following AssertionFailure occurs:
{noformat}
org.hibernate.AssertionFailure: The root entity needs to specify an identifier
at org.hibernate.metamodel.source.annotations.entity.RootEntitySourceImpl.getIdentifierSource(RootEntitySourceImpl.java:63)
at org.hibernate.metamodel.source.binder.Binder.bindIdentifier(Binder.java:309)
at org.hibernate.metamodel.source.binder.Binder.makeRootEntityBinding(Binder.java:183)
at org.hibernate.metamodel.source.binder.Binder.createBasicEntityBinding(Binder.java:159)
at org.hibernate.metamodel.source.binder.Binder.doCreateEntityBinding(Binder.java:147)
at org.hibernate.metamodel.source.binder.Binder.createEntityBinding(Binder.java:132)
at org.hibernate.metamodel.source.binder.Binder.processEntityHierarchy(Binder.java:108)
at org.hibernate.metamodel.source.annotations.AnnotationMetadataSourceProcessorImpl.processMappingMetadata(AnnotationMetadataSourceProcessorImpl.java:134)
at org.hibernate.metamodel.source.internal.MetadataImpl.bindMappingMetadata(MetadataImpl.java:195)
at org.hibernate.metamodel.source.internal.MetadataImpl.<init>(MetadataImpl.java:165)
at org.hibernate.metamodel.source.internal.MetadataBuilderImpl.buildMetadata(MetadataBuilderImpl.java:83)
at org.hibernate.metamodel.MetadataSources.buildMetadata(MetadataSources.java:112)
{noformat}
It appears that this is happening because EntityClass is always instantiated with a null parent from EntityHierarchyBuilder.createEntityHierarchies(AnnotationBindingContext bindingContext) line 105:
{code}
EntityClass rootEntityClass = new EntityClass(
rootClassInfo,
null,
defaultAccessType,
hierarchyInheritanceType,
bindingContext
);
{code}
and therefore EntityClass.findIdAnnotations(DotName idAnnotationType) never loops through the parent hierarchy to find the @Id annotation in the MappedSuperclass.
This was working in Hibernate 3.6.*.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months