[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2920?page=c...
]
Wolfgang Knauf updated HHH-2920:
--------------------------------
Attachment: InheritanceTablePerClass.ear
I see this problem also in EJB3 entity beans with inheritance strategy
"TABLE_PER_CLASS":
@Entity
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public abstract class Base implements Serializable
{
...
Attached is a full EJB sample, runnable on JBoss 4.2/5.0 (project export of Eclipse
3.4/WebTools 3.0 with sources). After deploying, it can be tested by browsing to
http://localhost:8080/InheritanceTablePerClassWeb/
When loading a list of base classes, all subclass fields are null. The union subclause in
the query does not work on HSQLDB. The described workaround to change all NULL expressions
to "cast (null as VARCHAR)" results in a working query, but I see no chance to
pre-configure this query in the entity manager.
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: Hibernate Core
Issue Type: Bug
Affects Versions: 3.2.5
Environment: Java 1.5 - Hypersonic DB - Standalone application
Reporter: Andrea Silva
Priority: Minor
Attachments: AuctionIntegrationTest.java, InheritanceTablePerClass.ear, 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