-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: joined-subclass failing to recognize new object on parent
PostPosted: Fri May 27, 2005 9:51 am 
Newbie

Joined: Mon Apr 11, 2005 1:14 pm
Posts: 7
Location: Charlotte, NC
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0

In this scenario I have 3 objects/tables:
A Parent class - BusinessRelationship
A joined-subclass - Client
A collection on the parent of addresses.

It seems that the primary cache in the session is not associating new addresses with the collection on the parent if the address is persisted individually(yes, I set the client on the address prior to persisting).

Is this a known limitation or could I be doing something wrong? I would think that regardless of how you added a particular record, the cache should recognize it.



Mapping documents:
<class name="BusinessRelationship" table="BUSINESS_RELATIONSHIP">
...
<set name="addresses" inverse="true" cascade="all,delete-orphan">
<key column="BUSINESS_RELATIONSHIP_ID"/>
<one-to-many class="Address"/>
</set>
...

<joined-subclass name="Client" extends="BusinessRelationship" table="CLIENT">
<key column="BUSINESS_RELATIONSHIP_ID"/>
...

<class name="Address" table="CONTACT_ADDRESS">
...
<many-to-one name="businessRelationship" column="BUSINESS_RELATIONSHIP_ID"/>
...

Code between sessionFactory.openSession() and session.close():

session.update(obj);

Full stack trace of any exception that occurs:
N/A

Name and version of the database you are using:
Oracle 9i

The generated SQL (show_sql=true):
********************** Setting up: testBusinessRelationshipAddress ************************************
Hibernate: select ENTITY_ID_SEQ.nextval from dual
Hibernate: select ENTITY_ID_SEQ.nextval from dual
Hibernate: insert into BUSINESS_RELATIONSHIP (VERSION, TYPE_CODE, BUSINESS_REFERENCE_NAME, BUSINESS_REFERENCE_ID, PRIOR_ID, ADMINISTRATOR_CODE, LAST_CHANGED_DATE, LAST_CHANGED_BY, EFFECTIVE_DATE, TERMINATION_DATE, CREATION_DATE, HEIRARCHY_LEVEL_1, HEIRARCHY_LEVEL_2, HEIRARCHY_LEVEL_3, HEIRARCHY_LEVEL_4, HEIRARCHY_LEVEL_5, BUSINESS_RELATIONSHIP_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into CLIENT (PARENT_BIZ_RELATIONSHIP_ID, SIGNED_DATE, THIRD_PARTY_IND, CROSS_SELL_IND, INACTIVE_DATE, REACTIVATE_DATE, DATE_FIRST_LOAN_CLOSED, CROSS_SELL_COMMENT, CREDIT_CARD_CODE, PROFITABILITY_STATUS, VOE_CODE, VOE_COMPANY, VOE_PHONE, SHARED_FEE_ACCOUNT_TYPE, SHARED_FEE_PAYMENT_TYPE, SHARED_FEE_AMOUNT_TYPE, SHARED_FEE_PERCENT, SHARED_FEE_AMOUNT, SHARED_FEE_PAYMENT_TERM, SHARED_FEE_DISCLOSE_ON_HUD, BUSINESS_RELATIONSHIP_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into CONTACT_ADDRESS (VERSION, BUSINESS_RELATIONSHIP_ID, TYPE_CODE, ADDRESS1, ADDRESS2, CITY, STATE_CODE, ZIP, COUNTRY_CODE, CONTACT_ADDRESS_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Client Id 7359
Address Count on Client after persisting new client with a new address: 1
Hibernate: select ENTITY_ID_SEQ.nextval from dual
Hibernate: insert into CONTACT_ADDRESS (VERSION, BUSINESS_RELATIONSHIP_ID, TYPE_CODE, ADDRESS1, ADDRESS2, CITY, STATE_CODE, ZIP, COUNTRY_CODE, CONTACT_ADDRESS_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Address Count on Client after persisting new address with client: 1
Hibernate: select ENTITY_ID_SEQ.nextval from dual
Hibernate: insert into CONTACT_ADDRESS (VERSION, BUSINESS_RELATIONSHIP_ID, TYPE_CODE, ADDRESS1, ADDRESS2, CITY, STATE_CODE, ZIP, COUNTRY_CODE, CONTACT_ADDRESS_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update BUSINESS_RELATIONSHIP set VERSION=?, TYPE_CODE=?, BUSINESS_REFERENCE_NAME=?, BUSINESS_REFERENCE_ID=?, PRIOR_ID=?, ADMINISTRATOR_CODE=?, LAST_CHANGED_DATE=?, LAST_CHANGED_BY=?, EFFECTIVE_DATE=?, TERMINATION_DATE=?, CREATION_DATE=?, HEIRARCHY_LEVEL_1=?, HEIRARCHY_LEVEL_2=?, HEIRARCHY_LEVEL_3=?, HEIRARCHY_LEVEL_4=?, HEIRARCHY_LEVEL_5=? where BUSINESS_RELATIONSHIP_ID=? and VERSION=?
Address Count on Client after persisting client with third address: 2
********************** Shutting down: testBusinessRelationshipAddress ************************************


Code:
Client client = getNewPersistedClient(); //adds one address
Long clientId = client.getId();
System.out.println("Client Id " + clientId);
System.out.println("Address Count on Client after persisting new client with a new address: " + client.getAddresses().size());
   
Address a = getAddress();
a.setBusinessRelationship(client);
Long id = delegate.persistAddress(a);
   
client = delegate.getClient(clientId);
System.out.println("Address Count on Client after persisting new address with client: " + client.getAddresses().size());
   

//On Client
client = delegate.getClient(clientId);
Set addresses = client.getAddresses();
Address a1 = getAddress();
a1.setBusinessRelationship(client);
addresses.add(a1);
client.setAddresses(addresses);

delegate.persistClient(client);

Client savedClient2 = delegate.getClient(clientId);
System.out.println("Address Count on Client after persisting client with third address: " + client.getAddresses().size());
assertNotNull(savedClient2);

Set as = savedClient2.getAddresses();
assertNotNull(as);
assertTrue(as.size() == 3);
assertEquals(addressZip,((Address)as.toArray()[0]).getZip());


Top
 Profile  
 
 Post subject: More Information:
PostPosted: Fri May 27, 2005 11:31 am 
Newbie

Joined: Mon Apr 11, 2005 1:14 pm
Posts: 7
Location: Charlotte, NC

3 records really do get added to the database.

I tried the latest hibernate patch 3.0.5 and the problem still exists.

Thanks in advance to anyone who might be able to explain this anomaly.


Top
 Profile  
 
 Post subject: Submit Bug?
PostPosted: Tue May 31, 2005 9:24 am 
Newbie

Joined: Mon Apr 11, 2005 1:14 pm
Posts: 7
Location: Charlotte, NC
Does anyone know where I should submit bugs to? I feel this is a problem with the current release of Hibernate and would like to communicate it as such.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 31, 2005 1:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Do not submit nonsense bug reports. Read and understand and debug and fix your error.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.