-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate hangs on Batch Insert
PostPosted: Wed Sep 03, 2003 9:40 am 
Newbie

Joined: Tue Sep 02, 2003 9:17 am
Posts: 9
Location: London
Hi

I've got a problem with Hibernate hanging when performing a batch insert. It does this whenever inserting a cascade, i.e. a List of dependent objects. My mapping files and the debug logs are shown below. The strange thing is that the customer object and all dependent objects *are* actually stored in the database, but execution never gets past the point:

session.save(customer);

even though no exceptions are thrown. The Customer obejct mapping is shown here:

<class name="uk.co.blueyonder.dialup.dao.Customer" table="CMS_ACCOUNTS">

<composite-id name="id" class="uk.co.blueyonder.dialup.dao.CustomerCompositeId">
<key-property name="accountNumber" type="integer" column="Account_Number" />
<key-property name="siteID" type="integer" column="Site_ID" />
</composite-id>

<property name="password" column="Cms_Password" type="string" />

... more properties....

<list name="telephoneAccounts" table="CMS_TELEPHONES" cascade="all">
<key>
<column name="Account_Number" />
<column name="Site_ID" />
</key>
<index column="ID" /> <!-- Oracle sequence -->
<!--<element column="ID" type="long" /> -->
<one-to-many class="uk.co.blueyonder.dialup.dao.TelephoneAccount" />
</list>

</class>


The full log is shown below.


DEBUG - Saving Customer object...
DEBUG - saving [uk.co.blueyonder.dialup.dao.Customer#uk.co.blueyonder.dialup.dao.CustomerCompositeId@b6b2a5[accountNumber=666,siteID=14]]
DEBUG - processing cascades for: uk.co.blueyonder.dialup.dao.Customer
DEBUG - done processing cascades for: uk.co.blueyonder.dialup.dao.Customer
DEBUG - Wrapped collection in role: uk.co.blueyonder.dialup.dao.Customer.telephoneAccounts
DEBUG - running Session.finalize()
DEBUG - running Session.finalize()
DEBUG - processing cascades for: uk.co.blueyonder.dialup.dao.Customer
DEBUG - cascading to collection: uk.co.blueyonder.dialup.dao.Customer.telephoneAccounts
DEBUG - cascading to saveOrUpdate()
DEBUG - unsaved-value strategy NULL
DEBUG - saveOrUpdate() unsaved instance with id: null
DEBUG - about to open: 0 open PreparedStatements, 0 open ResultSets
DEBUG - prepared statement get: select telephone_account_seq.nextval from dual
Hibernate: select telephone_account_seq.nextval from dual
DEBUG - preparing statement
DEBUG - Sequence identifier generated: 22
DEBUG - done closing: 0 open PreparedStatements, 0 open ResultSets
DEBUG - closing statement
DEBUG - saving [uk.co.blueyonder.dialup.dao.TelephoneAccount#22]
DEBUG - cascading to saveOrUpdate()
DEBUG - unsaved-value strategy NULL
DEBUG - saveOrUpdate() unsaved instance with id: null
DEBUG - about to open: 0 open PreparedStatements, 0 open ResultSets
DEBUG - prepared statement get: select telephone_account_seq.nextval from dual
Hibernate: select telephone_account_seq.nextval from dual
DEBUG - preparing statement
DEBUG - Sequence identifier generated: 23
DEBUG - done closing: 0 open PreparedStatements, 0 open ResultSets
DEBUG - closing statement
DEBUG - saving [uk.co.blueyonder.dialup.dao.TelephoneAccount#23]
DEBUG - done processing cascades for: uk.co.blueyonder.dialup.dao.Customer
DEBUG - Flushing Customer object...
DEBUG - flushing session
DEBUG - processing cascades for: uk.co.blueyonder.dialup.dao.Customer
DEBUG - cascading to collection: uk.co.blueyonder.dialup.dao.Customer.telephoneAccounts
DEBUG - cascading to saveOrUpdate()
DEBUG - saveOrUpdate() persistent instance
DEBUG - cascading to saveOrUpdate()
DEBUG - saveOrUpdate() persistent instance
DEBUG - done processing cascades for: uk.co.blueyonder.dialup.dao.Customer
DEBUG - Flushing entities and processing referenced collections
DEBUG - Collection found: [uk.co.blueyonder.dialup.dao.Customer.telephoneAccounts#uk.co.blueyonder.dialup.dao.CustomerCompositeId@b6b2a5[accountNumber=666,siteID=14]], was: [<unreferenced>]
DEBUG - Processing unreferenced collections
DEBUG - Scheduling collection removes/(re)creates/updates
DEBUG - Flushed: 3 insertions, 0 updates, 0 deletions to 3 objects
DEBUG - Flushed: 1 (re)creations, 0 updates, 0 removals to 1 collections
DEBUG - executing flush
DEBUG - Inserting entity: uk.co.blueyonder.dialup.dao.Customer#uk.co.blueyonder.dialup.dao.CustomerCompositeId@b6b2a5[accountNumber=666,siteID=14]
DEBUG - about to open: 0 open PreparedStatements, 0 open ResultSets
DEBUG - prepared statement get: insert into CMS_ACCOUNTS (Cms_Password, Service_Type, Last_Bill_Value, Last_Bill_Date, Previous_Bill_Value, Previous_Bill_Date, Customer_Name, Address_Line_1, Address_Line_2, Address_Line_3, Address_Line_4, Postcode, Account_Number, Site_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into CMS_ACCOUNTS (Cms_Password, Service_Type, Last_Bill_Value, Last_Bill_Date, Previous_Bill_Value, Previous_Bill_Date, Customer_Name, Address_Line_1, Address_Line_2, Address_Line_3, Address_Line_4, Postcode, Account_Number, Site_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
DEBUG - preparing statement
DEBUG - Dehydrating entity: uk.co.blueyonder.dialup.dao.Customer#uk.co.blueyonder.dialup.dao.CustomerCompositeId@b6b2a5[accountNumber=666,siteID=14]
DEBUG - binding 'foo' to parameter: 1
DEBUG - binding 'B' to parameter: 2
DEBUG - binding '100.0' to parameter: 3
DEBUG - binding '03 September 2003' to parameter: 4
DEBUG - binding '200.0' to parameter: 5
DEBUG - binding '03 September 2003' to parameter: 6
DEBUG - binding 'Rory Winston' to parameter: 7
DEBUG - binding 'Address1' to parameter: 8
DEBUG - binding 'Address2' to parameter: 9
DEBUG - binding 'Address3' to parameter: 10
DEBUG - binding 'Address4' to parameter: 11
DEBUG - binding 'sw4 123' to parameter: 12
DEBUG - binding '666' to parameter: 13
DEBUG - binding '14' to parameter: 14
DEBUG - Adding to batch
DEBUG - Inserting entity: uk.co.blueyonder.dialup.dao.TelephoneAccount#22
DEBUG - Executing batch size: 1
DEBUG - done closing: 0 open PreparedStatements, 0 open ResultSets
DEBUG - closing statement
DEBUG - about to open: 0 open PreparedStatements, 0 open ResultSets
DEBUG - prepared statement get: insert into CMS_TELEPHONES (Account_Number, Site_ID, Unformatted_Telephone_Number, Formatted_Telephone_Number, ID) values (?, ?, ?, ?, ?)
Hibernate: insert into CMS_TELEPHONES (Account_Number, Site_ID, Unformatted_Telephone_Number, Formatted_Telephone_Number, ID) values (?, ?, ?, ?, ?)
DEBUG - preparing statement
DEBUG - Dehydrating entity: uk.co.blueyonder.dialup.dao.TelephoneAccount#22
DEBUG - binding '666' to parameter: 1
DEBUG - binding '14' to parameter: 2
DEBUG - binding '123' to parameter: 3
DEBUG - binding '123-456-789' to parameter: 4
DEBUG - binding '22' to parameter: 5
DEBUG - Adding to batch
DEBUG - Inserting entity: uk.co.blueyonder.dialup.dao.TelephoneAccount#23
DEBUG - Dehydrating entity: uk.co.blueyonder.dialup.dao.TelephoneAccount#23
DEBUG - binding '666' to parameter: 1
DEBUG - binding '14' to parameter: 2
DEBUG - binding '456' to parameter: 3
DEBUG - binding '123-456-789' to parameter: 4
DEBUG - binding '23' to parameter: 5
DEBUG - Adding to batch
DEBUG - Executing batch size: 2
DEBUG - done closing: 0 open PreparedStatements, 0 open ResultSets
DEBUG - closing statement
DEBUG - Inserting collection: uk.co.blueyonder.dialup.dao.Customer.telephoneAccounts#uk.co.blueyonder.dialup.dao.CustomerCompositeId@b6b2a5[accountNumber=666,siteID=14]
DEBUG - about to open: 0 open PreparedStatements, 0 open ResultSets
DEBUG - prepared statement get: update CMS_TELEPHONES set Account_Number=?, Site_ID=?, ID=? where ID=?
Hibernate: update CMS_TELEPHONES set Account_Number=?, Site_ID=?, ID=? where ID=?
DEBUG - preparing statement
DEBUG - binding '666' to parameter: 1
DEBUG - binding '14' to parameter: 2
DEBUG - binding '22' to parameter: 4
DEBUG - binding '0' to parameter: 3
DEBUG - Adding to batch
DEBUG - binding '666' to parameter: 1
DEBUG - binding '14' to parameter: 2
DEBUG - binding '23' to parameter: 4
DEBUG - binding '1' to parameter: 3
DEBUG - Adding to batch
DEBUG - done inserting collection
DEBUG - Executing batch size: 2


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 2:21 am 
Newbie

Joined: Wed Sep 03, 2003 5:50 am
Posts: 8
Exceus me !It is convenient that you post the source code snippen.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 6:25 am 
Newbie

Joined: Tue Sep 02, 2003 9:17 am
Posts: 9
Location: London
Ok, here's the code(slightly altered).

public CustomerTest() {
int idOfTheBeast = 666;
int siteIdOfTheBeast = 20;

// Get Hibernate Session from JNDI
try {
logger.debug("Getting CustomerSessionFactory from JNDI...");
Context ctx = new InitialContext();
factory = (SessionFactory) ctx.lookup("CustomerSessionFactory");
} catch (NamingException e) {
e.printStackTrace();
}

if (factory == null)
throw new HibernateSessionInitException();

try {
sess = factory.openSession();
} catch (HibernateException e1) {
e1.printStackTrace();
}

// Create the Customer object
logger.debug("Instantiating new Customer...");
customer = new Customer();

logger.debug("Creating Composite ID instance...");
CustomerCompositeId id = new CustomerCompositeId();

logger.debug("Setting Customer properties...");
id.setAccountNumber(idOfTheBeast);
id.setSiteID(siteIdOfTheBeast);

customer.setAddressLine1("Address1");
customer.setAddressLine2("Address2");
customer.setAddressLine3("Address3");
customer.setAddressLine4("Address4");
customer.setLastBillDate(new Date());
customer.setLastBillValue((float) 100.0);
customer.setName("Rory Winston");
customer.setPassword("foo");
customer.setPostCode("sw4 123");
customer.setPreviousBillDate(new Date());
customer.setPreviousBillValue((float) 200.0);
customer.setServiceType("B");
customer.setId(id);

// Now add some dependant objects
List accounts = new ArrayList();


TelephoneAccount account = new TelephoneAccount();

account.setAccountNumber(idOfTheBeast);
account.setSiteID(siteIdOfTheBeast);
account.setFormattedTelephoneNumber("123-456-789");
account.setUnformattedTelephoneNumber("456");

TelephoneAccount account2 = new TelephoneAccount();

account2.setAccountNumber(idOfTheBeast);
account2.setSiteID(siteIdOfTheBeast);
account2.setFormattedTelephoneNumber("123-456-789");
account2.setUnformattedTelephoneNumber("123");

accounts.add(account);
accounts.add(account2);

logger.debug("The number of account entries in the set is: " + accounts.size());

customer.setTelephoneAccounts(accounts);

logger.debug("Saving Customer object...");
try {
// Now save the main object
sess.save(customer); // **** HANGS *****

sess.flush();
logger.debug("Closing Session...");
sess.close();

logger.debug("Hibernate Done");
} catch (Exception e2) {
logger.error("Exception occured saving customer - " + e2.getClass().getName() + ": " + e2.getMessage(), e2);
e2.printStackTrace();
}

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.