-->
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.  [ 2 posts ] 
Author Message
 Post subject: InnoDB and MyISAM
PostPosted: Fri Feb 06, 2004 7:22 am 
Newbie

Joined: Tue Feb 03, 2004 1:49 pm
Posts: 16
I have a mappng:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
   
<hibernate-mapping>
   <class name="com.Composite" table="composites">
      <composite-id name="comp_id" class="com.CompositePK">
         <key-property name="id" column="id" type="java.lang.Long"/>
         <key-property name="name" column="name"   type="java.lang.String"/>
      </composite-id>
      <version name="version" type="java.lang.Long" unsaved-value="null"/>
      <bag name="children" inverse="true" lazy="true" cascade="all-delete-orphan">
         <key>
            <column name="id_fk"/>
            <column name="name_fk"/>
         </key>
         <one-to-many class="com.Composite"/>
      </bag>
      <many-to-one name="parent" cascade="save-update" class="com.Composite">
         <column name="id_fk"/>
         <column name="name_fk"/>
      </many-to-one>
      <property name="description" type="java.lang.String"/>
   </class>
</hibernate-mapping>


and, code
Code:
  public void testAddComposite() throws Exception {
    System.out.println("testAddComposite");
    Session session = sessionFactory.openSession();
    CompositePK pk = new CompositePK(new Long(1), "parent");
    Composite parent = new Composite();
    parent.setComp_id(pk);
    parent.setDescription("parent_desc");
    session.save(parent);
    session.flush();
    //
    session.disconnect();
    session.reconnect();
    List list = session.find("from com.Composite");
    assertEquals(1, list.size());
    Composite p = (Composite)list.iterator().next();
    assertNull(p.getChildren());
  }


The unit test passed. But, the database does not contains the created data if default table type is InnoDB. No problems to MyISAM type.

Any idea?

_________________
mzoom@homealone


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2004 7:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Use the hibernate transaction api


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