-->
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: sequence and lists
PostPosted: Fri Jan 07, 2005 4:33 am 
Newbie

Joined: Fri Jan 07, 2005 3:46 am
Posts: 2
My situation:
I have several unidirectional parent-child associations in my application. They are all using lists as I need to load and store them in a particular sequence. As id generators I used uuid.hex everywhere. Everything was ok, the index and foreign key fields of my tables where filled in correctly and automatically by hibernate.

For several reasons I changed the id generator to sequence (the corresponding fields in the db-table where changed from char(32) to bigint). It was the only change I did, but now hibernate doesnt set the key and index fields anymore. They are simply empty in the database. A solution (which is definitely not my personal favorite) is to make a bidirectional association like shown in:

http://www.hibernate.org/155.html

but that does not work for the lists index field as stated in the documentation.

I also changed some id generators from uuid.hex to assigned with long as datatype for the primary key. Surprisingly, here the key and index fields are filled correctly.

My questions:
- Do I need any further configuration for this automatic filling of key and index fields if I use sequence as my id generator?

- Is it at all a good idea to use sequences and list associations together?

- Is it allowed or even required to have the key and index fields as properties in my mapping class?

I had these fields in my classes when I used uuid.hex. For childs where the parent class uses assigned its better to remove them as their value seems to overwrite the hibernate generated values (e.G. the index field in the db is 0 in every row, but incremented correctly when the index field property is removed in the mapping class). For childs where the parent uses sequence it seems to make no difference.

To state it again: I only changed the generator class from uuid.hex to sequence and the automatic filling of the key and index fields of childs in list associations stopped working.

I would really appreciate some hint to solve that problem.

Hibernate version: 2.1

Mapping documents:

(generated by xdoclet)
Parent class mapping:
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.riva.besdc.ofen.OfenKorb"
        table="OfenKorb"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="id"
            type="long"
            unsaved-value="0"
        >
            <generator class="sequence">
                <param name="sequence">besdc</param>
            </generator>
        </id>

        <property
            name="sequenz"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="Sequenz"
        />

        <list
            name="zuschlag"
            table="Korbzuschlag"
            lazy="false"
            inverse="true"
            cascade="all-delete-orphan"
        >

              <key
                  column="KorbId"
              >
              </key>

              <index
                  column="Sequenz"
              />

              <one-to-many
                  class="com.riva.besdc.ofen.KorbZuschlag"
              />
        </list>

        <property
            name="korbNummer"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="Korbnummer"
        />

        <property
            name="chargeId"
            type="long"
            update="true"
            insert="true"
            access="property"
            column="chargenid"
        />

    </class>

</hibernate-mapping>


parent class source
Code:
/*
* Created on 23.11.2004 by martin
*
*/
package com.riva.besdc.ofen;

import java.util.List;

/**
* @author martin
*
* @hibernate.class
*    table="OfenKorb"
*/
public class OfenKorb
{
   private long id;
   private long chargeId;
   private int Sequenz;
   private List zuschlag;
   private int korbNummer;
   
   
   /**
    * @return Returns the id.
    * @hibernate.id
    *    generator-class="sequence"
    *  unsaved-value="0"
    * @hibernate.generator-param
    *    name="sequence"
    *    value="besdc"
    */
   public long getId() {
      return id;
   }
   /**
    * @param id The id to set.
    */
   public void setId(long id) {
      this.id = id;
   }
   /**
    * @return Returns the sequenz.
    * @hibernate.property
    *  column="Sequenz"
    */
   public int getSequenz() {
      return Sequenz;
   }
   /**
    * @param sequenz The sequenz to set.
    */
   public void setSequenz(int sequenz) {
      Sequenz = sequenz;
   }
   /**
    * @return Returns the zuschlag.
    * @hibernate.list
    *    table="Korbzuschlag"
    *  cascade="all-delete-orphan"
    *    inverse="true"
    * @hibernate.collection-key
    *    column="KorbId"
    * @hibernate.collection-index
    *    column="Sequenz"
    * @hibernate.collection-one-to-many
    *  class="com.riva.besdc.ofen.KorbZuschlag"
    */
   public List getZuschlag() {
      return zuschlag;
   }
   /**
    * @param zuschlag The zuschlag to set.
    */
   public void setZuschlag(List zuschlag) {
      this.zuschlag = zuschlag;
   }
   /**
    * @return Returns the korbNummer.
    * @hibernate.property
    *    column="Korbnummer"
    */
   public int getKorbNummer() {
      return korbNummer;
   }
   /**
    * @param korbNummer The korbNummer to set.
    */
   public void setKorbNummer(int korbNummer) {
      this.korbNummer = korbNummer;
   }
   /**
    * @return Returns the chargeId.
    * @hibernate.property
    *    column="chargenid"
    */
   public long getChargeId() {
      return chargeId;
   }
   /**
    * @param chargeId The chargeId to set.
    */
   public void setChargeId(long chargeId) {
      this.chargeId = chargeId;
   }
}


child class mapping
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.riva.besdc.ofen.KorbZuschlag"
        table="Korbzuschlag"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="id"
            type="long"
            unsaved-value="0"
        >
            <generator class="sequence">
                <param name="sequence">besdc</param>
            </generator>
        </id>

        <many-to-one
            name="korbId"
            class="com.riva.besdc.ofen.OfenKorb"
            cascade="all"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="KorbId"
            not-null="true"
        />

        <property
            name="menge"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="Menge"
        />

        <many-to-one
            name="zuschlag"
            class="com.riva.besdc.esw.StammZuschlag"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="ZuschlagId"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-KorbZuschlag.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


child class source
Code:
/*
* Created on 23.11.2004 by martin
*
*/
package com.riva.besdc.ofen;

import com.riva.besdc.esw.StammZuschlag;

/**
* @author martin
*
* @hibernate.class
*    table="Korbzuschlag"
*/
public class KorbZuschlag
{
   private long id;
   private OfenKorb korbId;
   private int Menge;
   private int Sequenz;
   private StammZuschlag zuschlag;
   /**
    * @return Returns the id.
    * @hibernate.id
    *    generator-class="sequence"
    *  unsaved-value="0"
    * @hibernate.generator-param
    *    name="sequence"
    *    value="besdc"
    */
   public long getId() {
      return id;
   }
   /**
    * @param id The id to set.
    */
   public void setId(long id) {
      this.id = id;
   }
   /**
    * @return Returns the korbId.
    * @hibernate.many-to-one
    *    column="KorbId"
    *    not-null="true"
    *    cascade="all"
    */
   public OfenKorb getKorbId() {
      return korbId;
   }
   /**
    * @param korbId The korbId to set.
    */
   public void setKorbId(OfenKorb korbId) {
      this.korbId = korbId;
   }
   /**
    * @return Returns the menge.
    * @hibernate.property
    *    column="Menge"
    */
   public int getMenge() {
      return Menge;
   }
   /**
    * @param menge The menge to set.
    */
   public void setMenge(int menge) {
      Menge = menge;
   }
/*   /**
    * @return Returns the sequenz.
    * @hibernate.property
    *    column="Sequenz"
    */
/*   public int getSequenz() {
      return Sequenz;
   }
   /**
    * @param sequenz The sequenz to set.
    */
/*   public void setSequenz(int sequenz) {
      Sequenz = sequenz;
   }*/
   /**
    * @return Returns the zuschlag.
    * @hibernate.many-to-one
    * class="com.riva.besdc.esw.StammZuschlag"
    * column="ZuschlagId"
    */
   public StammZuschlag getZuschlag() {
      return zuschlag;
   }
   /**
    * @param zuschlag The zuschlag to set.
    */
   public void setZuschlag(StammZuschlag zuschlag) {
      this.zuschlag = zuschlag;
   }
}


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

As I use Spring's HibernateDaoTemplate its only:

getHibernateTemplate().update(charge);

or

getHibernateTemplate().save(charge);

if the charge is a new one.

Full stack trace of any exception that occurs:

There occurs no exception

Name and version of the database you are using:

postgresql 7.4.6


The generated SQL (show_sql=true):

I will post it later if needed.

Debug level Hibernate log excerpt:
Code:
...
3414 [main] INFO  net.sf.hibernate.cfg.Binder  - Mapping class: com.riva.besdc.ofen.KorbZuschlag -> Korbzuschlag
3414 [main] DEBUG net.sf.hibernate.cfg.Binder  - Mapped property: id -> id, type: long
3416 [main] DEBUG net.sf.hibernate.cfg.Binder  - Mapped property: menge -> Menge, type: integer
3416 [main] DEBUG net.sf.hibernate.cfg.Binder  - Mapped property: sequenz -> Sequenz, type: integer
3417 [main] DEBUG net.sf.hibernate.cfg.Binder  - Mapped property: zuschlag -> ZuschlagId, type: com.riva.besdc.esw.StammZuschlag
...
3619 [main] INFO  net.sf.hibernate.cfg.Binder  - Mapping class: com.riva.besdc.ofen.OfenKorb -> OfenKorb
3619 [main] DEBUG net.sf.hibernate.cfg.Binder  - Mapped property: id -> id, type: long
3620 [main] DEBUG net.sf.hibernate.cfg.Binder  - Mapped property: sequenz -> Sequenz, type: integer
3620 [main] DEBUG net.sf.hibernate.cfg.Binder  - Mapped property: zuschlag, type: java.util.List
3621 [main] DEBUG net.sf.hibernate.cfg.Binder  - Mapped property: korbNummer -> Korbnummer, type: integer
3621 [main] DEBUG net.sf.hibernate.cfg.Binder  - Mapped property: chargeId -> chargenid, type: long
...
112137 [http-8080-Processor25] DEBUG org.springframework.orm.hibernate.SessionFactoryUtils  - Opening Hibernate session
112137 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - opened session
112137 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - updating [com.riva.besdc.ofen.OfenCharge#27010]
112138 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - processing cascades for: com.riva.besdc.ofen.OfenCharge
112138 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to collection: com.riva.besdc.ofen.OfenCharge.korb
112138 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to saveOrUpdate()
112138 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value: 0
112138 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saveOrUpdate() unsaved instance
112139 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - about to open: 0 open PreparedStatements, 0 open ResultSets
112139 [http-8080-Processor25] DEBUG net.sf.hibernate.SQL  - select nextval ('besdc')
112139 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - preparing statement
112141 [http-8080-Processor25] DEBUG net.sf.hibernate.id.SequenceGenerator  - Sequence identifier generated: 1000043
112141 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - done closing: 0 open PreparedStatements, 0 open ResultSets
112142 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - closing statement
112142 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - generated identifier: 1000043
112142 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saving [com.riva.besdc.ofen.OfenKorb#1000043]
112142 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - processing cascades for: com.riva.besdc.ofen.OfenKorb
112142 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - done processing cascades for: com.riva.besdc.ofen.OfenKorb
112144 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.WrapVisitor  - Wrapped collection in role: com.riva.besdc.ofen.OfenKorb.zuschlag
112147 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - processing cascades for: com.riva.besdc.ofen.OfenKorb
112147 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to collection: com.riva.besdc.ofen.OfenKorb.zuschlag
112147 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to saveOrUpdate()
112147 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value: 0
112148 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saveOrUpdate() unsaved instance
112148 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - about to open: 0 open PreparedStatements, 0 open ResultSets
112148 [http-8080-Processor25] DEBUG net.sf.hibernate.SQL  - select nextval ('besdc')
112148 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - preparing statement
112149 [http-8080-Processor25] DEBUG net.sf.hibernate.id.SequenceGenerator  - Sequence identifier generated: 1000044
112149 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - done closing: 0 open PreparedStatements, 0 open ResultSets
112149 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - closing statement
112149 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - generated identifier: 1000044
112150 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saving [com.riva.besdc.ofen.KorbZuschlag#1000044]
112150 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value strategy NULL
112150 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to saveOrUpdate()
112150 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value: 0
112150 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saveOrUpdate() unsaved instance
112150 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - about to open: 0 open PreparedStatements, 0 open ResultSets
112150 [http-8080-Processor25] DEBUG net.sf.hibernate.SQL  - select nextval ('besdc')
112150 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - preparing statement
112152 [http-8080-Processor25] DEBUG net.sf.hibernate.id.SequenceGenerator  - Sequence identifier generated: 1000045
112152 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - done closing: 0 open PreparedStatements, 0 open ResultSets
112152 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - closing statement
112152 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - generated identifier: 1000045
112152 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saving [com.riva.besdc.ofen.KorbZuschlag#1000045]
112152 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value strategy NULL
112152 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to saveOrUpdate()
112152 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value: 0
112153 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saveOrUpdate() unsaved instance
112153 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - about to open: 0 open PreparedStatements, 0 open ResultSets
112153 [http-8080-Processor25] DEBUG net.sf.hibernate.SQL  - select nextval ('besdc')
112153 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - preparing statement
112154 [http-8080-Processor25] DEBUG net.sf.hibernate.id.SequenceGenerator  - Sequence identifier generated: 1000046
112154 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - done closing: 0 open PreparedStatements, 0 open ResultSets
112154 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - closing statement
112154 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - generated identifier: 1000046
112155 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saving [com.riva.besdc.ofen.KorbZuschlag#1000046]
112155 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value strategy NULL
112155 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - done processing cascades for: com.riva.besdc.ofen.OfenKorb
112155 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to collection: com.riva.besdc.ofen.OfenCharge.verbrauch
112155 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to saveOrUpdate()
112156 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value: 0
112156 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saveOrUpdate() previously saved instance with id: 1000023
112156 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - updating [com.riva.besdc.ofen.OfenVerbrauch#1000023]
112156 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to saveOrUpdate()
112156 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value: 0
112156 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saveOrUpdate() previously saved instance with id: 1000042
112156 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - updating [com.riva.besdc.ofen.OfenVerbrauch#1000042]
112156 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to collection: com.riva.besdc.ofen.OfenCharge.warteZeit
112156 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to collection: com.riva.besdc.ofen.OfenCharge.pfannenzusatz
112156 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to collection: com.riva.besdc.ofen.OfenCharge.analysen
112156 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - done processing cascades for: com.riva.besdc.ofen.OfenCharge
112157 [http-8080-Processor25] DEBUG org.springframework.orm.hibernate.HibernateTemplate  - Eagerly flushing Hibernate session
112157 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - flushing session
112157 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - processing cascades for: com.riva.besdc.ofen.OfenCharge
112157 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to collection: com.riva.besdc.ofen.OfenCharge.korb
112157 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to saveOrUpdate()
112157 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saveOrUpdate() persistent instance
112157 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to collection: com.riva.besdc.ofen.OfenCharge.verbrauch
112157 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to saveOrUpdate()
112157 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saveOrUpdate() persistent instance
112157 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to saveOrUpdate()
112157 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saveOrUpdate() persistent instance
112157 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to collection: com.riva.besdc.ofen.OfenCharge.warteZeit
112157 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to collection: com.riva.besdc.ofen.OfenCharge.pfannenzusatz
112158 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to collection: com.riva.besdc.ofen.OfenCharge.analysen
112158 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - done processing cascades for: com.riva.besdc.ofen.OfenCharge
112158 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - processing cascades for: com.riva.besdc.ofen.OfenKorb
112158 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to collection: com.riva.besdc.ofen.OfenKorb.zuschlag
112158 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to saveOrUpdate()
112158 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saveOrUpdate() persistent instance
112158 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to saveOrUpdate()
112158 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saveOrUpdate() persistent instance
112158 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - cascading to saveOrUpdate()
112158 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - saveOrUpdate() persistent instance
112158 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - done processing cascades for: com.riva.besdc.ofen.OfenKorb
112159 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Collection dirty: [com.riva.besdc.ofen.OfenCharge.korb#27010]
112159 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Collection dirty: [com.riva.besdc.ofen.OfenCharge.verbrauch#27010]
112159 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Collection dirty: [com.riva.besdc.ofen.OfenCharge.warteZeit#27010]
112161 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Collection dirty: [com.riva.besdc.ofen.OfenCharge.pfannenzusatz#27010]
112161 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Collection dirty: [com.riva.besdc.ofen.OfenCharge.analysen#27010]
112161 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Flushing entities and processing referenced collections
112161 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Updating entity: [com.riva.besdc.ofen.OfenCharge#27010]
112161 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Collection found: [com.riva.besdc.ofen.OfenCharge.korb#27010], was: [com.riva.besdc.ofen.OfenCharge.korb#27010]
112161 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Collection found: [com.riva.besdc.ofen.OfenCharge.verbrauch#27010], was: [com.riva.besdc.ofen.OfenCharge.verbrauch#27010]
112161 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Collection found: [com.riva.besdc.ofen.OfenCharge.warteZeit#27010], was: [com.riva.besdc.ofen.OfenCharge.warteZeit#27010]
112162 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Collection found: [com.riva.besdc.ofen.OfenCharge.pfannenzusatz#27010], was: [com.riva.besdc.ofen.OfenCharge.pfannenzusatz#27010]
112162 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Collection found: [com.riva.besdc.ofen.OfenCharge.analysen#27010], was: [com.riva.besdc.ofen.OfenCharge.analysen#27010]
112164 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Collection found: [com.riva.besdc.ofen.OfenKorb.zuschlag#1000043], was: [<unreferenced>]
112165 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Updating entity: [com.riva.besdc.ofen.OfenVerbrauch#1000023]
112165 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Updating entity: [com.riva.besdc.ofen.OfenVerbrauch#1000042]
112165 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Processing unreferenced collections
112165 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Scheduling collection removes/(re)creates/updates
112174 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Flushed: 4 insertions, 3 updates, 0 deletions to 7 objects
112175 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - Flushed: 1 (re)creations, 5 updates, 0 removals to 6 collections
112175 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.Printer  - listing entities:
112176 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.Printer  - com.riva.besdc.ofen.OfenKorb{zuschlag=[KorbZuschlag#1000044, KorbZuschlag#1000045, KorbZuschlag#1000046], korbNummer=1, chargeId=27010, sequenz=0, id=1000043}
112177 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.Printer  - com.riva.besdc.ofen.KorbZuschlag{zuschlag=StammZuschlag#24, sequenz=0, menge=3000, id=1000046}
112177 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.Printer  - com.riva.besdc.ofen.OfenVerbrauch{zuschlag=StammZuschlag#3, sequenz=0, menge=1000, id=1000023}
112177 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.Printer  - com.riva.besdc.ofen.OfenVerbrauch{zuschlag=StammZuschlag#26, sequenz=1, menge=3000, id=1000042}
112177 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.Printer  - com.riva.besdc.ofen.KorbZuschlag{zuschlag=StammZuschlag#23, sequenz=0, menge=2000, id=1000045}
112177 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.Printer  - com.riva.besdc.ofen.KorbZuschlag{zuschlag=StammZuschlag#22, sequenz=0, menge=1000, id=1000044}
112190 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.Printer  - com.riva.besdc.ofen.OfenCharge{verbrauch=[OfenVerbrauch#1000023, OfenVerbrauch#1000042], abstichZeit=00:00:53, abstichGewicht=0, warteZeit=[], pfannenzusatz=[], abstichTemperatur=0, pfanne=0, powerOn=0, korb=[OfenKorb#1000043], energie=0, id=27010, analysen=[]}
112190 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - executing flush
112191 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Inserting entity: [com.riva.besdc.ofen.OfenKorb#1000043]
112191 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - about to open: 0 open PreparedStatements, 0 open ResultSets
112191 [http-8080-Processor25] DEBUG net.sf.hibernate.SQL  - insert into OfenKorb (Sequenz, Korbnummer, chargenid, id) values (?, ?, ?, ?)
112191 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - preparing statement
112191 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Dehydrating entity: [com.riva.besdc.ofen.OfenKorb#1000043]
112191 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '0' to parameter: 1
112191 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '1' to parameter: 2
112191 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '27010' to parameter: 3
112192 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '1000043' to parameter: 4
112192 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - Adding to batch
112192 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Inserting entity: [com.riva.besdc.ofen.KorbZuschlag#1000044]
112192 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - Executing batch size: 1
112195 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - done closing: 0 open PreparedStatements, 0 open ResultSets
112195 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - closing statement
112195 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - about to open: 0 open PreparedStatements, 0 open ResultSets
112195 [http-8080-Processor25] DEBUG net.sf.hibernate.SQL  - insert into Korbzuschlag (Menge, Sequenz, ZuschlagId, id) values (?, ?, ?, ?)
112196 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - preparing statement
112196 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Dehydrating entity: [com.riva.besdc.ofen.KorbZuschlag#1000044]
112196 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '1000' to parameter: 1
112196 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '0' to parameter: 2
112196 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value strategy NULL
112196 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '22' to parameter: 3
112196 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '1000044' to parameter: 4
112196 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - Adding to batch
112197 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Inserting entity: [com.riva.besdc.ofen.KorbZuschlag#1000045]
112197 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - reusing prepared statement
112197 [http-8080-Processor25] DEBUG net.sf.hibernate.SQL  - insert into Korbzuschlag (Menge, Sequenz, ZuschlagId, id) values (?, ?, ?, ?)
112197 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Dehydrating entity: [com.riva.besdc.ofen.KorbZuschlag#1000045]
112197 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '2000' to parameter: 1
112197 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '0' to parameter: 2
112197 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value strategy NULL
112197 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '23' to parameter: 3
112197 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '1000045' to parameter: 4
112198 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - Adding to batch
112198 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Inserting entity: [com.riva.besdc.ofen.KorbZuschlag#1000046]
112204 [Finalizer] DEBUG net.sf.hibernate.impl.SessionImpl  - running Session.finalize()
112204 [Finalizer] DEBUG net.sf.hibernate.impl.SessionImpl  - running Session.finalize()
112204 [Finalizer] DEBUG net.sf.hibernate.impl.SessionImpl  - running Session.finalize()
112205 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - reusing prepared statement
112205 [http-8080-Processor25] DEBUG net.sf.hibernate.SQL  - insert into Korbzuschlag (Menge, Sequenz, ZuschlagId, id) values (?, ?, ?, ?)
112205 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Dehydrating entity: [com.riva.besdc.ofen.KorbZuschlag#1000046]
112205 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '3000' to parameter: 1
112205 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '0' to parameter: 2
112205 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value strategy NULL
112207 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '24' to parameter: 3
112208 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '1000046' to parameter: 4
112208 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - Adding to batch
112208 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - Executing batch size: 3
112215 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - done closing: 0 open PreparedStatements, 0 open ResultSets
112215 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - closing statement
112215 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Updating entity: [com.riva.besdc.ofen.OfenCharge#27010]
112215 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - about to open: 0 open PreparedStatements, 0 open ResultSets
112215 [http-8080-Processor25] DEBUG net.sf.hibernate.SQL  - update OfenCharge set Abstichgewicht=?, Abstichtemperatur=?, Abstichzeit=?, Energie=?, Pfanne=?, PowerOn=? where ID=?
112215 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - preparing statement
112216 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Dehydrating entity: [com.riva.besdc.ofen.OfenCharge#27010]
112216 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '0' to parameter: 1
112216 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '0' to parameter: 2
112216 [http-8080-Processor25] DEBUG net.sf.hibernate.type.TimeType  - binding '00:00:53' to parameter: 3
112218 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '0' to parameter: 4
112218 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '0' to parameter: 5
112218 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '0' to parameter: 6
112219 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '27010' to parameter: 7
112219 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - Adding to batch
112219 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Updating entity: [com.riva.besdc.ofen.OfenVerbrauch#1000023]
112219 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - Executing batch size: 1
112222 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - done closing: 0 open PreparedStatements, 0 open ResultSets
112223 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - closing statement
112223 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - about to open: 0 open PreparedStatements, 0 open ResultSets
112223 [http-8080-Processor25] DEBUG net.sf.hibernate.SQL  - update Ofenverbrauch set Menge=?, Sequenz=?, StoffId=? where id=?
112223 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - preparing statement
112223 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Dehydrating entity: [com.riva.besdc.ofen.OfenVerbrauch#1000023]
112223 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '1000' to parameter: 1
112223 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '0' to parameter: 2
112223 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value strategy NULL
112224 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '3' to parameter: 3
112224 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '1000023' to parameter: 4
112224 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - Adding to batch
112224 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Updating entity: [com.riva.besdc.ofen.OfenVerbrauch#1000042]
112225 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - reusing prepared statement
112225 [http-8080-Processor25] DEBUG net.sf.hibernate.SQL  - update Ofenverbrauch set Menge=?, Sequenz=?, StoffId=? where id=?
112225 [http-8080-Processor25] DEBUG net.sf.hibernate.persister.EntityPersister  - Dehydrating entity: [com.riva.besdc.ofen.OfenVerbrauch#1000042]
112225 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '3000' to parameter: 1
112225 [http-8080-Processor25] DEBUG net.sf.hibernate.type.IntegerType  - binding '1' to parameter: 2
112225 [http-8080-Processor25] DEBUG net.sf.hibernate.engine.Cascades  - id unsaved-value strategy NULL
112225 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '26' to parameter: 3
112225 [http-8080-Processor25] DEBUG net.sf.hibernate.type.LongType  - binding '1000042' to parameter: 4
112226 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - Adding to batch
112226 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - Executing batch size: 2
112247 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - done closing: 0 open PreparedStatements, 0 open ResultSets
112248 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.BatcherImpl  - closing statement
112248 [http-8080-Processor25] DEBUG net.sf.hibernate.collection.BasicCollectionPersister  - Deleting rows of collection: [com.riva.besdc.ofen.OfenCharge.verbrauch#27010]
112249 [http-8080-Processor25] DEBUG net.sf.hibernate.collection.BasicCollectionPersister  - no rows to delete
112249 [http-8080-Processor25] DEBUG net.sf.hibernate.collection.BasicCollectionPersister  - Updating rows of collection: com.riva.besdc.ofen.OfenCharge.verbrauch#27010
112249 [http-8080-Processor25] DEBUG net.sf.hibernate.collection.BasicCollectionPersister  - done updating rows: 0 updated
112249 [http-8080-Processor25] DEBUG net.sf.hibernate.collection.BasicCollectionPersister  - Inserting rows of collection: [com.riva.besdc.ofen.OfenCharge.verbrauch#27010]
112249 [http-8080-Processor25] DEBUG net.sf.hibernate.collection.BasicCollectionPersister  - done inserting rows: 0 inserted
112249 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - post flush
112249 [http-8080-Processor25] DEBUG org.springframework.orm.hibernate.SessionFactoryUtils  - Closing Hibernate session
112250 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - closing session
112250 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - disconnecting session
112250 [http-8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl  - transaction completion


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 4:41 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
are you sure you understand what inverse=true mean?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 07, 2005 4:51 am 
Newbie

Joined: Fri Jan 07, 2005 3:46 am
Posts: 2
Ok, you got me. Although the wiki says it is easy to understand, I have not fully understood what it means. BUT: I did not need it before. With my uuid.hex ids and unidirectional list associations it worked perfectly without setting inverse. What you see in the post above is my try to get this automatic property filling back to work. Before, my child mapping looked like that:

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.riva.besdc.ofen.OfenWarteZeit"
        table="OfenWartezeiten"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="id"
            type="long"
            unsaved-value="0"
        >
            <generator class="sequence">
                <param name="sequence">besdc</param>
            </generator>
        </id>

        <property
            name="chargeId"
            type="long"
            update="true"
            insert="true"
            access="property"
            column="chargeID"
        />

        <property
            name="dauer"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="Dauer"
        />

        <property
            name="sequenz"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="Sequenz"
        />

        <many-to-one
            name="warteZeit"
            class="com.riva.besdc.esw.StammWarteZeiten"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="WarteID"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-OfenWarteZeit.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>



chargeId is the foreign key field and sequenz is the index field. With uuid.hex it worked, with sequence it doesnt.

All I did was changing the xdoclet tags from:

/**
* @return Returns the id.
* @hibernate.id
* generator-class="uuid.hex"
*/

to:

/**
* @return Returns the id.
* @hibernate.id
* generator-class="sequence"
* unsaved-value="0"
* @hibernate.generator-param
* name="sequence"
* value="besdc"
*/

everywhere. (As said above, I also changed the field types in the db and the corresponding property datatypes in the mapping class)


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.