[Hibernate-JIRA] Created: (HHH-5836) Mapping collection of entities with same name and notnull constraints from two different entities results in duplicate property mapping of Backref
by Milan Brich (JIRA)
Mapping collection of entities with same name and notnull constraints from two different entities results in duplicate property mapping of Backref
--------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-5836
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5836
Project: Hibernate Core
Issue Type: Bug
Components: annotations
Affects Versions: 3.5.6
Reporter: Milan Brich
Attachments: hibernate-backref-bug.zip
When two entities have OneToMany relationship to third entity and the collection name is same in both entities and nullable is set to false. Then exception written below is thrown.
Caused by: org.hibernate.MappingException: Duplicate property mapping of _parentsBackref found in cz.csas.persistence.test.Parent
at org.hibernate.mapping.PersistentClass.checkPropertyDuplication(PersistentClass.java:483)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:473)
at org.hibernate.mapping.RootClass.validate(RootClass.java:236)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1193)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1378)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:892)
... 58 more
Attached annotated entities.
--
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, 1 month
[Hibernate-JIRA] Created: (ANN-654) Generated SQL includes a column named "null" when referencing a map entry by key and using @LazyCollection(LazyCollectionOption.EXTRA)
by Paul Roe (JIRA)
Generated SQL includes a column named "null" when referencing a map entry by key and using @LazyCollection(LazyCollectionOption.EXTRA)
--------------------------------------------------------------------------------------------------------------------------------------
Key: ANN-654
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-654
Project: Hibernate Annotations
Issue Type: Bug
Components: binder
Affects Versions: 3.2.0.ga
Environment: Oracle 10g, hibernate 3.2
Reporter: Paul Roe
We have an Product entity with a map of RegionProduct by Region.
@MapKey(name="region")
@OneToMany(mappedBy="product", targetEntity= RegionProductImpl.class, fetch = FetchType.LAZY)
@LazyCollection(LazyCollectionOption.EXTRA)
private Map<Region, RegionProduct> regionProducts = new HashMap<Region, RegionProduct>();
When accessing an element of the map by key, the SQL that is generated includes a "null" column in the WHERE condition.
where regionprod0_.PROD_ID=? and regionprod0_.null=?
resulting in the stack trace
org.hibernate.exception.SQLGrammarException: could not collection element by index
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1841)
at org.hibernate.loader.entity.CollectionElementLoader.loadElement(CollectionElementLoader.java:72)
at org.hibernate.persister.collection.OneToManyPersister.getElementByIndex(OneToManyPersister.java:360)
at org.hibernate.collection.AbstractPersistentCollection.readElementByIndex(AbstractPersistentCollection.java:158)
at org.hibernate.collection.PersistentMap.get(PersistentMap.java:146)
Iterating over the collection works successfully, but populates the entire collection, which is what Extra-Lazy is meant to avoid.
--
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, 1 month
[Hibernate-JIRA] Created: (HHH-4953) Inconsistent behavior when fetching cached subclass entities from 2L
by Guenther Demetz (JIRA)
Inconsistent behavior when fetching cached subclass entities from 2L
--------------------------------------------------------------------
Key: HHH-4953
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4953
Project: Hibernate Core
Issue Type: Bug
Components: caching (L2)
Affects Versions: 3.5.0-CR-2, 3.5.0-CR-1, 3.5.0-Beta-4, 3.5.0-Beta-3, 3.5.0-Beta-2, 3.5.0.Beta-1, 3.3.1, 3.2.5
Environment: Hibernate3.5.0CR2,HSQLDB, EHCache as 2L-cache Impl
Reporter: Guenther Demetz
Attachments: Test2LCache.jar
Enabling the hibernate second-level cache is leading to inconsistent behavior when fetching cached subclass entities as opposed to fetching non-cached subclass entities.
For more informations, please see
https://forum.hibernate.org/viewtopic.php?f=1&t=1002880&p=2425931#p2425931
Testcase attached.
Cause:
IMHO the bug consists in the fact, that
persister.getRootEntityName() instead to persister.getEntityName() is passed as 3thrd parameter
to the constructor of CacheKey in most places where CacheKey is used, for example in DefaultLoadEventListener.java:
new CacheKey(
event.getEntityId(),
persister.getIdentifierType(),
persister.getRootEntityName(),
source.getEntityMode(),
source.getFactory()
In this way the real entity name get swallowed and the type-saveness is not guaranteed anymore.
Workaround:
Subclass2 tofind = null;
try {
tofind = (Subclass2) em.find(Subclass2.class,"identifier1");
}
catch (ClassCastException cc) {
// swallow , this is a workaround
}
--
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, 1 month