-->
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: Fail to update a data
PostPosted: Mon May 09, 2005 2:40 pm 
Newbie

Joined: Mon May 09, 2005 1:22 pm
Posts: 2
Hi, I´m failing in update a data.
I´m using Hibernate version:2.1.7c .
I have a many-to-many relationship.
Here my Mapping documents:
Client mapping
Code:
<hibernate-mapping>
    <class
        name="foo.Client"
        table="CLIENT"
        dynamic-update="true"
        dynamic-insert="true"
    >

        <id
            name="codigo"
            column="CLNT_CD_CLIENT"
            type="java.lang.Integer"
        >
            <generator class="identity">
            </generator>
        </id>

        <version
            name="versionDate"
            type="java.util.Calendar"
            column="XXXX_DH_ALT"
            access="property"
            unsaved-value="undefined"
        />

        <set
            name="clientTelephone"
            lazy="true"
            inverse="true"
            cascade="save-update"
            sort="unsorted"
        >
              <key
                  column="CLNT_CD_CLIENT"
              >
              </key>

              <one-to-many
                  class="foo.ClientTelephone"
              />
        </set>
    </class>
</hibernate-mapping>


Telephone mapping
Code:
<hibernate-mapping>
    <class
        name="bar.Telephone"
        table="NUMERO_TELEFONE"
        dynamic-update="true"
        dynamic-insert="true"
    >

        <id
            name="code"
            column="NRTL_CD_NUMERO_TELEFONE"
            type="java.lang.Integer"
        >
            <generator class="identity">
            </generator>
        </id>

        <version
            name="versionDate"
            type="java.util.Calendar"
            column="XXXX_DH_ALT"
            access="property"
            unsaved-value="undefined"
        />

        <set
            name="clientTelephone"
            lazy="true"
            inverse="true"
            cascade="none"
            sort="unsorted"
        >
              <key
                  column="NRTL_TN_NUMERO"
              >
              </key>

              <one-to-many
                  class="foo.ClientTelephone"
              />
        </set>
    </class>
</hibernate-mapping>


ClientTelephone mapping
Code:
<hibernate-mapping>
    <class
        name="foo.ClientTelephone"
        table="CLIENT_TELEPHONE"
        dynamic-update="true"
        dynamic-insert="true"
    >

        <id
            name="code"
            column="CLTL_CD_CLIENT_TELEPHONE"
            type="java.lang.Integer"
        >
            <generator class="identity">
            </generator>
        </id>

        <version
            name="versionDate"
            type="java.util.Calendar"
            column="XXXX_DH_ALT"
            access="property"
            unsaved-value="undefined"
        />

        <many-to-one
            name="client"
            class="foo.Client"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="CLNT_CD_CLIENT"
        />

        <many-to-one
            name="telephone"
            class="bar.Telephone"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="NRTL_CD_NUMERO_TELEFONE"
        />
    </class>
</hibernate-mapping>


I´ve already tried to insert a new data and then tried to update it or retrieved an existing data and then tried to update it. But in this 2 cases,
i got this full stack trace:
Code:
java.lang.RuntimeException: net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: foo.Clientetelephone.versionDate
   foo.HibernateUtil.commitTransaction(HibernateUtil.java:98)
   foo.HibernateDAO.commitTransaction(HibernateDAO.java:131)
   foo.HibernateDAO.update(HibernateDAO.java:63)
   at foo.clientetelephone.test.HibernateClientetelephoneDAOTest.testUpdate(HibernateClientetelephoneDAOTest.java:121)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: foo.Clientetelephone.versionDate
   at net.sf.hibernate.impl.SessionImpl.checkNullability(SessionImpl.java:1286)
   at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2591)
   at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2478)
   at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2280)
   at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2259)
   at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
   foo.HibernateUtil.commitTransaction(HibernateUtil.java:94)
   ... 16 more


Debuggin Hibernate, in the method
Code:
Versioning.increment()

it received the version with a not null value and a
Code:
net.sf.hibernate.type.CalendarType object

But
Code:
CalendarType.next()
returns always null.
How to solve this problem ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 8:25 am 
Newbie

Joined: Mon May 09, 2005 1:22 pm
Posts: 2
Here is the code from CalendarType class where it increments the version.

Code:
public class CalendarType extends MutableType implements VersionType {

....

   public Object next(Object current) {
      return seed();
   }

   public Object seed() {
      return null; //Calendar.getInstance();
   }

...
}


I think this could be a bug because in Hibernate 2.1.6, Calendar.getInstance() is not commented and it works fine.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 9:09 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This was already fixed.


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.