[Hibernate-JIRA] Created: (HHH-3121) Using fetch="subselect" and second level cache causes NullPointerException
by Adam Brod (JIRA)
Using fetch="subselect" and second level cache causes NullPointerException
--------------------------------------------------------------------------
Key: HHH-3121
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3121
Project: Hibernate3
Issue Type: Bug
Components: caching (L2)
Affects Versions: 3.2.6
Environment: Oracle 10g
Reporter: Adam Brod
I've been tuning some of our mappings to use fetch="subselect" to reduce the number of DB queries. However, I have run into two cases where I get the exception below. In both cases, I was loading a list of Videos, which are mapped to a list of other objects. (In this example, Media is the superclass of Video.) I apologize that I can't upload a full working example, but I will include the relevant mapping info.
<class name="Media" table="media" lazy="false" discriminator-value="0">
<cache usage="nonstrict-read-write"/>
<id name="id" column="id" type="long">
<generator class="seqhilo"><param name="sequence">hibernate_hi_sequence</param><param name="max_lo">500</param></generator>
</id>
...
<list name="tags" lazy="true" table="media_tags" cascade="save-update" fetch="subselect">
<cache usage="nonstrict-read-write"/>
<key column="media_id"/>
<list-index column="idx"/>
<many-to-many column="tag_id" class="com.brightcove.catalog.Tag"/>
</list>
...
<subclass name="Video" lazy="false" discriminator-value="1">
...
</subclass>
</class>
<class name="Tag" table="tag">
...
</class>
The HQL being executed is just a simple "from Video v where v.publisher_id = :pubId".
The line of code where the exception is generated in Video.getDTO() is accessing the Tags list:
for (Tag tag : getTags()) {
tags.add(tag.getDTO());
}
I've debugged into the Hibernate source to see where the NPE comes from (CollectionLoadContext line 298).
if ( persister.isVersioned() ) {
versionComparator = persister.getOwnerEntityPersister().getVersionType().getComparator();
final Object collectionOwner = getLoadContext().getPersistenceContext().getCollectionOwner( lce.getKey(), persister );
version = getLoadContext().getPersistenceContext().getEntry( collectionOwner ).getVersion(); //NPE!
}
It seems that "collectionOwner" is null, so calling getEntry(collectionOwner) returns null. Calling getVersion() on a null entry is what throws the NPE.
java.lang.NullPointerException
at org.hibernate.engine.loading.CollectionLoadContext.addCollectionToCache(CollectionLoadContext.java:298)
at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:256)
at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:222)
at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:195)
at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:877)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:865)
at org.hibernate.loader.Loader.doQuery(Loader.java:729)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadCollectionSubselect(Loader.java:2066)
at org.hibernate.loader.collection.SubselectCollectionLoader.initialize(SubselectCollectionLoader.java:58)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:109)
at org.hibernate.collection.PersistentList.size(PersistentList.java:91)
at com.brightcove.catalog.EconomicEntity.populateDTO(EconomicEntity.java:460)
at com.brightcove.catalog.Media.populateDTO(Media.java:192)
at com.brightcove.catalog.Video.populateDTO(Video.java:854)
at com.brightcove.catalog.Video.getDTO(Video.java:783)
at com.brightcove.catalog.Video.getDTO(Video.java:756)
--
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
13 years, 10 months
[Hibernate-JIRA] Created: (ANN-687) orm.xml - cleanup respecting column names
by darren hartford (JIRA)
orm.xml - cleanup respecting column names
-----------------------------------------
Key: ANN-687
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-687
Project: Hibernate Annotations
Issue Type: Bug
Components: binder
Affects Versions: 3.3.0.ga
Environment: mysql 5, MS SQL 2000, Win2000, hibernate 3.2.4
Reporter: darren hartford
couple of issues with orm.xml mapping file that is not fully implemented and needs cleanup.
many-to-many table mapping not respecting column names.
http://forum.hibernate.org/viewtopic.php?t=982330
id-class not respecting column names (end of an old issue, repeated with different scenario).
http://opensource.atlassian.com/projects/hibernate/browse/ANN-361
<id-class class="MyTestId"/>
<attributes>
<id name="compoundOne">
<column name="COMPOUND_ONE"/>
</id>
<id name="compoundTwo">
<column name="COMPOUND_TWO"/>
</id>
...
WARNING: Preparing the statement failed: Invalid column name 'compoundOne'.
WARNING: Preparing the statement failed: Invalid column name 'compoundTwo'.
==========
Use case and urgency of issue related to external technology integration.
-DTO should not require hibernate-annotations to be used in client-code, but is required when using annotations. orm.xml approach removes this limitation.
-GWT 1.4 does not work with java 1.5/annotated DTO. Although everyone keeps pushing it off saying 'GWT 1.5 is on the way', it is not and solutions that should have been working to work around that limitation need to be working correctly.
--
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
13 years, 10 months
[Hibernate-JIRA] Created: (HHH-5056) Criteria API with ProjectionList and Unique result
by Ahmed Ali Elsayed Ali Soliman (JIRA)
Criteria API with ProjectionList and Unique result
--------------------------------------------------
Key: HHH-5056
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5056
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.5.0-CR-2
Environment: Hibernate 3.3.2, Oracel 11g
Reporter: Ahmed Ali Elsayed Ali Soliman
Priority: Critical
when you make a select statement with Criteria API & use ProjectionList to retrieve some columns then use the unique result
make at least 2 projection list (2 columns or more)
ProjectionList projectionList = Projections.projectionList() .add(Projections.property("ColumnA")) .add(Projections.property("ColumnB"));
criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
the result must be retrieved in 2 dimensional array of Object(Object[][])
but the result are one dimensional array with one column only.
Note:- when you remove the unique result it works fine but when you add it, it make this behavior.
--
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
13 years, 10 months
[Hibernate-JIRA] Created: (ANN-472) @UniqueConstraint declaration is not friendly towards inheritance or reflection
by Ted Bergeron (JIRA)
@UniqueConstraint declaration is not friendly towards inheritance or reflection
-------------------------------------------------------------------------------
Key: ANN-472
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-472
Project: Hibernate Annotations
Type: Improvement
Versions: 3.2.0.ga
Environment: Hibernate 3.2 GA
Reporter: Ted Bergeron
The current way to define a composite unique constraint is limiting.
@Table(name="tbl_sky",
uniqueConstraints = {@UniqueConstraint(columnNames={"month", "day"})}
)
Suppose I have an abstract base class called A that gives me Id and Name, subclassed by abstract class B that gives me Customer. Then I have many concrete classes that subclass B. For all of these, I'd want the combination of Name and Customer to be unique. As I do not use @Table with abstract base classes, I currently have to repeat: uniqueConstraints = {@UniqueConstraint(columnNames={"name", "customer_id"})} on all concrete classes.
If we had an alternate way to define these constraints at the property level (as XDoclet did with hibernate 2), I could define this in the base classes and inherit the constraint declaration.
The other need is that I would like to use reflection to scan the properties and apply proper validations in the view layer. With @Column(unique = true) this is easy to do. The view layer makes an AJAX call and all is well. For a composite constraint, it does not work well currently.
--
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
13 years, 10 months
[Hibernate-JIRA] Created: (HHH-4939) Bidirectional OneToOne mapping with FK and composite PK sharing a column throws MappingException
by Chris Wilson (JIRA)
Bidirectional OneToOne mapping with FK and composite PK sharing a column throws MappingException
------------------------------------------------------------------------------------------------
Key: HHH-4939
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4939
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Reporter: Chris Wilson
Attachments: HibernateAnnotationMappingOneToOneTest.java
A bidirectional one-to-one mapping, where the owning side's column is part of a composite primary key, fails to configure, possibly because OneToOneType#getColumnSpan returns zero instead of the actual number of columns used by the join.
When the foreign key column used is not also part of the primary key, or the composite primary key contains only a single column, then the mapping doesn't fail.
{code}
org.hibernate.MappingException: broken column mapping for: journeyComment.id of: org.wfp.rita.test.hibernate.HibernateAnnotationMappingOneToOneTest$Journey
at org.hibernate.persister.entity.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:143)
at org.hibernate.persister.entity.AbstractPropertyMapping.initIdentifierPropertyPaths(AbstractPropertyMapping.java:206)
at org.hibernate.persister.entity.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:181)
at org.hibernate.persister.entity.AbstractEntityPersister.initOrdinaryPropertyPaths(AbstractEntityPersister.java:1725)
at org.hibernate.persister.entity.AbstractEntityPersister.initPropertyPaths(AbstractEntityPersister.java:1755)
at org.hibernate.persister.entity.AbstractEntityPersister.postConstruct(AbstractEntityPersister.java:2932)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:431)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:267)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.wfp.rita.test.base.HibernateTestBase.buildSessionFactory(HibernateTestBase.java:93)
at org.wfp.rita.test.base.HibernateTestBase.setUp(HibernateTestBase.java:106)
at junit.framework.TestCase.runBare(TestCase.java:128)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
{code}
Test case attached. Change HibernateTestBase to org.hibernate.test.annotations.TestCase to run under Hibernate.
--
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
13 years, 11 months