[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2920?page=c...
]
Rando Valt commented on HHH-2920:
---------------------------------
I'd propose to fix this issue in Hibernate by overriding getSelectClauseNullString(int
sqlType) method in the org.hibernate.dialect.HSQLDialect class. The implementation of this
method would be:
@Override
public String getSelectClauseNullString(int sqlType) {
String typeName = getTypeName(sqlType, 1, 1, 0);
//trim off the length/precision/scale
int loc = typeName.indexOf('(');
if (loc != -1) {
typeName = typeName.substring(0, loc);
}
return "cast(null as " + typeName + ")";
}
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