[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-2920) Polymorphic association with explicit table_per_class strategy: properties of subclass are not retrieved by queries.

Andrea Silva (JIRA) noreply at atlassian.com
Mon Oct 29 14:49:39 EDT 2007


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2920?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrea Silva updated HHH-2920:
------------------------------

    Attachment: AuctionIntegrationTest.java

Added test case

> 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: AuctionIntegrationTest.java, 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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list