[Hibernate-JIRA] Created: (HHH-3528) FETCH JOIN query doesn't work in a StatelessSession
by Oscar Pearce (JIRA)
FETCH JOIN query doesn't work in a StatelessSession
---------------------------------------------------
Key: HHH-3528
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3528
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1, 3.2.6
Environment: Hibernate core 3.3.1 and 3.2.6, HSQLDB 1.8.0 and PostgreSQL 8.1
Reporter: Oscar Pearce
Attachments: slsession.zip, StatelessSessionImpl.patch
A query with an explicit JOIN FETCH, such as the following:
from DomainObject obj join fetch obj.a
fails when run in a StatelessSession, giving the following exception:
org.hibernate.SessionException: proxies cannot be fetched by a stateless session
at org.hibernate.impl.StatelessSessionImpl.immediateLoad(StatelessSessionImpl.java:243)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:95)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:140)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
The attached zip file contains a small project (buildable with maven) that demonstrates the problem. Applying the patch to StatelessSessionImpl fixes it.
The cause of the problem is with the internalLoad method of StatelessSessionImpl. The method currently first tries to generate a proxy and, only if no proxy is available, then it uses the data that it loaded as part of the query. The patch changes it to use any loaded data from the query in preference to creating a proxy. (I suspect that the check for eager should be omitted, and that an exception should be thrown if getEntity fails and no proxy can be created, but I don't know the code well enough to be sure of that.)
--
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
15 years, 9 months
[Hibernate-JIRA] Created: (HHH-3522) Null value cannot be cache using hibernate
by Lao Shing Kit (JIRA)
Null value cannot be cache using hibernate
--------------------------------------------
Key: HHH-3522
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3522
Project: Hibernate Core
Issue Type: Bug
Components: caching (L2)
Environment: Hibernate 3.3.1, Ehcache 1.5, Java1.5
Reporter: Lao Shing Kit
I'm using Hibernate with 2nd level cache using Ehcache. We found that if the result returned using session.get() (searching by primary key) is NULL, the value will not be cached in 1st level and 2nd level cache and SQL will be fired to database. There is no problem if the value retuurned is not null for the same entity. I have debug using the hibernate and ehcache source and I'm sure that the cache is enabled and called properly. Actually the null value is expected to be cached also. I have browser all hibernate and ehcache documentation and forum and no related config is available. So, is it a bug?
Thanks all for your help!
--
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
15 years, 9 months
[Hibernate-JIRA] Created: (HHH-3455) Component polymorphism (<subclass> within <component>)
by Jasper Blues (JIRA)
Component polymorphism (<subclass> within <component>)
------------------------------------------------------
Key: HHH-3455
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3455
Project: Hibernate3
Issue Type: Improvement
Components: core
Reporter: Jasper Blues
The following feature request occurs on the Hibernate forums from time to time - it would be especially useful in mapping complex legacy schemas:
<class name="Critter">
<component name="breathingStrategy" class="BreathingStrategy">
<discriminator column="BREATHING_STRATEGY" type="integer" />
<subclass name="Lungs" discriminator-value="0" >
<set name="alveoli">
<key column="CRITTER_ID" />
<one-to-many class="Alveolus" />
</set>
</subclass>
<subclass name="Gills" discriminator-value="1" >
<set name="alveoli">
<key column="CRITTER_ID" />
<one-to-many class="Gill" />
</set>
</subclass>
</component>
</class>
Will a patch that implements this feature be accepted?
What do you think if there was an option to inherit a discriminator from the owning entity? How about some convention over configuration? By default the discriminator from the owning entity is inherited, unless one is supplied at the component level.
Would an equivalent annotation mapping be required?
--
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
15 years, 9 months
[Hibernate-JIRA] Created: (HHH-2920) Polymorphic association with explicit table_per_class strategy: properties of subclass are not retrieved by queries.
by Andrea Silva (JIRA)
Polymorphic association with explicit table_per_class strategy: properties of subclass are not retrieved by queries.
--------------------------------------------------------------------------------------------------------------------
Key: HHH-2920
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2920
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.5
Environment: Java 1.5 - Hypersonic DB - Standalone application
Reporter: Andrea Silva
Priority: Minor
Attachments: src.zip
Item class has a one-to-many association to Bid. Bid class has a subclass called CashBid (meaningless design I know, but that's not the point). If I create and save an instance of Item with an associated CashBid, when I query for items the properties defined in CashBid are not retrieved.
NB Bid is not mapped as abstract.
Here is a code snippet:
...
// First Session
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
Bid bid = new CashBid(new BigDecimal(100.0d), "euro");
Item item = new Item("pc");
Serializable bidId = session.save(bid);
item.addBid(bid);
session.save(item);
transaction.commit();
session.close();
// Second Session
session = sessionFactory.openSession();
transaction = session.beginTransaction();
//session.load(CashBid.class, bidId);
Query query = session.createQuery("from Item");
List<Item> list = query.list();
for (Item item_ : list) {
System.out.println(item_);
}
transaction.commit();
session.close();
...
The bid in the item retrieved by the query is a CashBid (that's correct) but the properties that are defined in CashBid and not in Bid are null. If I uncomment the line
//session.load(CashBid.class, bidId);
the problem is not there anymore.
If Bid is not mapped as abstract the problem doesn't show.
My apologies if I'm just missing something very obvious.
Please find the source code and the mappings attached.
--
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
15 years, 10 months