-->
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.  [ 1 post ] 
Author Message
 Post subject: Component loading
PostPosted: Mon Sep 20, 2004 7:19 am 
Newbie

Joined: Mon Apr 19, 2004 9:48 am
Posts: 2
Location: Germany
Hello,

the following mapping works well with Hibernate 2.1.4. When using
Hibernate 3 the addresses of the address book are not loaded.

Thanks for any help.

Hibernate version: 3.0a

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="customer">
               
   <class name="Customer" table="customer">      
      <id name="id" column="id" type="string" access="field">
         <generator class="uuid.hex"/>
      </id>      
      
      <property name="customerNo" column="customer_no" type="string"/>
      <property name="status" column="status" type="string"/>
               
      <component name="addressBook" class="AddressBook" access="field">
         <bag name="addresses"
            access="field"
            cascade="all-delete-orphan">
            <key column="owner_id"/>
            <one-to-many class="Address"/>
         </bag>            
      </component>
   </class>         

</hibernate-mapping>

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="customer">

   <class name="Address" table="address">
      <id name="id" column="id" type="string" access="field">
         <generator class="uuid.hex"/>
      </id>      

      <property name="code"       type="string" access="field"/>
      <property name="salutation" type="string" access="field"/>      
      <property name="firstName"  type="string" access="field"/>
      <property name="lastName"   type="string" access="field"/>
      <property name="street"     type="string" access="field"/>
      <property name="street2"    type="string" access="field"/>
      <property name="postalCode" type="string" access="field"/>
      <property name="city"       type="string" access="field"/>
      <property name="phone"      type="string" access="field"/>
      <property name="fax"        type="string" access="field"/>      
   </class>      

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
   Customer c = (Customer)HibernateUtility.load(Customer.class, "2c909824ff00f23400ff00f2a2750001");
   out.println("Customer: " +c);
   out.println("AddressBook : " +c.getAddressBook().size());

   HibernateUtility.closeCurrentSession();


Full stack trace of any exception that occurs:
none

Name and version of the database you are using:
MySQL 4.1.4

Debug level Hibernate log excerpt:
DEBUG org.hibernate.impl.SessionImpl - opened session
DEBUG org.hibernate.event.DefaultLoadEventListener - loading entity: [customer.Customer#2c909824ff00f23400ff00f2a2750001]
DEBUG org.hibernate.event.DefaultLoadEventListener - attempting to resolve: [customer.Customer#2c909824ff00f23400ff00f2a2750001]
DEBUG org.hibernate.event.DefaultLoadEventListener - object not resolved in any cache: [customer.Customer#2c909824ff00f23400ff00f2a2750001]
DEBUG org.hibernate.persister.SingleTableEntityPersister - Materializing entity: [customer.Customer#2c909824ff00f23400ff00f2a2750001]
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open: 0 open PreparedStatements, 0 open ResultSets
DEBUG org.hibernate.SQL - select customer0_.id as id0_, customer0_.customer_no as customer2_0_0_, customer0_.status as status0_0_ from customer customer0_ where customer0_.id=?
Hibernate: select customer0_.id as id0_, customer0_.customer_no as customer2_0_0_, customer0_.status as status0_0_ from customer customer0_ where customer0_.id=?
DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
DEBUG org.hibernate.type.StringType - binding '2c909824ff00f23400ff00f2a2750001' to parameter: 1
DEBUG org.hibernate.loader.Loader - processing result set
DEBUG org.hibernate.loader.Loader - result row: EntityKey[customer.Customer#2c909824ff00f23400ff00f2a2750001]
DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: EntityKey[customer.Customer#2c909824ff00f23400ff00f2a2750001]
DEBUG org.hibernate.persister.BasicEntityPersister - Hydrating entity: [customer.Customer#2c909824ff00f23400ff00f2a2750001]
DEBUG org.hibernate.type.StringType - returning '123456' as column: customer2_0_0_
DEBUG org.hibernate.type.StringType - returning null as column: status0_0_
DEBUG org.hibernate.loader.Loader - done processing result set (1 rows)
DEBUG org.hibernate.jdbc.AbstractBatcher - done closing: 0 open PreparedStatements, 0 open ResultSets
DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
DEBUG org.hibernate.loader.Loader - total objects hydrated: 1
DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [customer.Customer#2c909824ff00f23400ff00f2a2750001]
DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [customer.Customer#2c909824ff00f23400ff00f2a2750001]
DEBUG org.hibernate.impl.SessionImpl - initializing non-lazy collections
DEBUG org.hibernate.event.AbstractFlushingEventListener - flushing session
DEBUG org.hibernate.engine.Cascades - processing cascades for: customer.Customer
DEBUG org.hibernate.engine.Cascades - done processing cascades for: customer.Customer
DEBUG org.hibernate.event.AbstractFlushingEventListener - Flushing entities and processing referenced collections
DEBUG org.hibernate.persister.AbstractEntityPersister - customer.Customer.addressBook is dirty
DEBUG org.hibernate.event.AbstractFlushingEventListener - Updating entity: [customer.Customer#2c909824ff00f23400ff00f2a2750001]
DEBUG org.hibernate.event.AbstractFlushingEventListener - Processing unreferenced collections
DEBUG org.hibernate.event.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
DEBUG org.hibernate.event.AbstractFlushingEventListener - Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
DEBUG org.hibernate.event.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
DEBUG org.hibernate.pretty.Printer - listing entities:
DEBUG org.hibernate.pretty.Printer - customer.Customer{customerNo=123456, addressBook=AddressBook{addresses=null}, status=null, id=2c909824ff00f23400ff00f2a2750001}
DEBUG org.hibernate.event.AbstractFlushingEventListener - executing flush
DEBUG org.hibernate.event.AbstractFlushingEventListener - post flush
DEBUG org.hibernate.impl.SessionImpl - closing session
DEBUG org.hibernate.impl.SessionImpl - disconnecting session
DEBUG org.hibernate.impl.SessionImpl - transaction completion[quote][/quote]


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

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.