Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [Teneo] id column get value from sequence
| |
Re: [Teneo] id column get value from sequence [message #84556 is a reply to message #84548] |
Wed, 23 May 2007 09:56 |
Anthony Lee Messages: 114 Registered: July 2009 |
Senior Member |
|
|
Martin,
I have db table already , so I cannot update schema in runtime.
I am using DB2 , I had set the primary key with Identity attribute.
Now it is OK.
1 questions need your help:
I create 1 Network object and 1 Label object,
then I add Label object into Network object,
then save().
stacktrace :
============================================================ ======
org.hibernate.StaleStateException: Batch update returned unexpected row
count from update [0]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatche d
(Expectations.java:61)
at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutco me
(Expectations.java:46)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch
(NonBatchingBatcher.java:24)
at org.hibernate.persister.entity.AbstractEntityPersister.updat e
(AbstractEntityPersister.java:2403)
at org.hibernate.persister.entity.AbstractEntityPersister.updat eOrInsert
(AbstractEntityPersister.java:2307
============================================================ ===
a fragment of mapping file as below:
============================================================ ==
<class entity-name="LogisticsNetwork" abstract="false" lazy="false"
table="SNOW.T_NETWORK1">
<bag name="labels" lazy="false" cascade="all,delete-orphan">
<key update="true">
<column name="network_id" not-null="false"
unique="false"/>
</key>
<one-to-many entity-name="Label"/>
</bag>
</class>
<class entity-name="Label" abstract="false" lazy="false"
table="SNOW.T_LABEL">
<id name="id" type="int" column="label_id" >
<generator class="native"/>
</id>
<property name="name" lazy="false" insert="true"
update="true" not-null="true" unique="false" type="java.lang.String">
<column not-null="true" unique="true"
name="label_name"/>
</property>
<property name="typeValue" lazy="false" not-null="false"
insert="true" update="true" unique="false" type="int">
<column not-null="false" unique="false"
name="label_type"/>
</property>
</class>
How can I work around this?
Reagrds,
Anthony
Martin Taal <mtaal@elver.org> wrote in
news:f312gj$deh$1@build.eclipse.org:
> Hi Anthony,
> Just setting these two annotations:
> @Id
> @GeneratedValue
>
> results in a native id mapping in hbm.
> Btw, it can be handy to use an edatatype for the id eattributes and
> then set the annotation on the edatatype.
>
> gr. Martin
>
> Anthony wrote:
>> Hi Martin,
>>
>> when id column's generator set as native ,
>>
>> I should make the id get value from some sequence , right?
>>
>>
>> Anthony
>
>
|
|
|
Re: [Teneo] id column get value from sequence [message #84560 is a reply to message #84556] |
Wed, 23 May 2007 10:13 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
My guess is that it expects that either network or label already exist and it tries to update them
instead of doing an insert. Can you debug into hibernate and check which one is the cause?
gr. Martin
Anthony wrote:
> Martin,
>
> I have db table already , so I cannot update schema in runtime.
>
> I am using DB2 , I had set the primary key with Identity attribute.
> Now it is OK.
>
>
> 1 questions need your help:
>
>
>
> I create 1 Network object and 1 Label object,
> then I add Label object into Network object,
> then save().
>
> stacktrace :
> ============================================================ ======
> org.hibernate.StaleStateException: Batch update returned unexpected row
> count from update [0]; actual row count: 0; expected: 1
> at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatche d
> (Expectations.java:61)
> at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutco me
> (Expectations.java:46)
> at org.hibernate.jdbc.NonBatchingBatcher.addToBatch
> (NonBatchingBatcher.java:24)
> at org.hibernate.persister.entity.AbstractEntityPersister.updat e
> (AbstractEntityPersister.java:2403)
> at org.hibernate.persister.entity.AbstractEntityPersister.updat eOrInsert
> (AbstractEntityPersister.java:2307
> ============================================================ ===
>
> a fragment of mapping file as below:
> ============================================================ ==
> <class entity-name="LogisticsNetwork" abstract="false" lazy="false"
> table="SNOW.T_NETWORK1">
>
> <bag name="labels" lazy="false" cascade="all,delete-orphan">
> <key update="true">
> <column name="network_id" not-null="false"
> unique="false"/>
> </key>
> <one-to-many entity-name="Label"/>
> </bag>
>
> </class>
>
> <class entity-name="Label" abstract="false" lazy="false"
> table="SNOW.T_LABEL">
> <id name="id" type="int" column="label_id" >
> <generator class="native"/>
> </id>
> <property name="name" lazy="false" insert="true"
> update="true" not-null="true" unique="false" type="java.lang.String">
> <column not-null="true" unique="true"
> name="label_name"/>
> </property>
> <property name="typeValue" lazy="false" not-null="false"
> insert="true" update="true" unique="false" type="int">
> <column not-null="false" unique="false"
> name="label_type"/>
> </property>
> </class>
>
>
>
> How can I work around this?
>
>
>
>
>
>
> Reagrds,
> Anthony
>
>
>
> Martin Taal <mtaal@elver.org> wrote in
> news:f312gj$deh$1@build.eclipse.org:
>
>> Hi Anthony,
>> Just setting these two annotations:
>> @Id
>> @GeneratedValue
>>
>> results in a native id mapping in hbm.
>> Btw, it can be handy to use an edatatype for the id eattributes and
>> then set the annotation on the edatatype.
>>
>> gr. Martin
>>
>> Anthony wrote:
>>> Hi Martin,
>>>
>>> when id column's generator set as native ,
>>>
>>> I should make the id get value from some sequence , right?
>>>
>>>
>>> Anthony
>>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: [Teneo] id column get value from sequence [message #84566 is a reply to message #84560] |
Wed, 23 May 2007 11:25 |
Anthony Lee Messages: 114 Registered: July 2009 |
Senior Member |
|
|
Martin,
In Hibernate ActionQueue's prepareActions() ,
the Label object is in collectionCreations ,but the
ExecutableAction's persister(is a OneToManyPersister)'s
sqlInsertRowString is "update ....."
and
sqlDeleteRowString also is "update..."
no "insert..." or "delete ..."
It seems some setting let hibernate think the Label should be exist in
table.
Anthony
> My guess is that it expects that either network or label already exist
> and it tries to update them instead of doing an insert. Can you debug
> into hibernate and check which one is the cause?
>
> gr. Martin
>
> Anthony wrote:
>> Martin,
>>
>> I have db table already , so I cannot update schema in runtime.
>>
>> I am using DB2 , I had set the primary key with Identity
>> attribute. Now it is OK.
>>
>>
>> 1 questions need your help:
>>
>>
>>
>> I create 1 Network object and 1 Label object,
>> then I add Label object into Network object,
>> then save().
>>
>> stacktrace :
>> ============================================================ ======
>> org.hibernate.StaleStateException: Batch update returned unexpected
>> row count from update [0]; actual row count: 0; expected: 1
>> at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatche d
>> (Expectations.java:61)
>> at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutco me
>> (Expectations.java:46)
>> at org.hibernate.jdbc.NonBatchingBatcher.addToBatch
>> (NonBatchingBatcher.java:24)
>> at org.hibernate.persister.entity.AbstractEntityPersister.updat e
>> (AbstractEntityPersister.java:2403)
>> at
>> org.hibernate.persister.entity.AbstractEntityPersister.updat eOrInsert
>> (AbstractEntityPersister.java:2307
>> ============================================================ ===
>>
>> a fragment of mapping file as below:
>> ============================================================ ==
>> <class entity-name="LogisticsNetwork" abstract="false" lazy="false"
>> table="SNOW.T_NETWORK1">
>>
>> <bag name="labels" lazy="false" cascade="all,delete-orphan">
>> <key update="true">
>> <column name="network_id" not-null="false"
>>
>> unique="false"/>
>> </key>
>> <one-to-many entity-name="Label"/>
>> </bag>
>>
>> </class>
>>
>> <class entity-name="Label" abstract="false" lazy="false"
>> table="SNOW.T_LABEL">
>> <id name="id" type="int" column="label_id" >
>> <generator class="native"/>
>> </id>
>> <property name="name" lazy="false" insert="true"
>> update="true" not-null="true" unique="false" type="java.lang.String">
>> <column not-null="true" unique="true"
>> name="label_name"/>
>> </property>
>> <property name="typeValue" lazy="false" not-null="false"
>> insert="true" update="true" unique="false" type="int">
>> <column not-null="false" unique="false"
>> name="label_type"/>
>> </property>
>> </class>
>>
>>
>>
>> How can I work around this?
>>
>>
>>
>>
>>
>>
>> Reagrds,
>> Anthony
>>
>>
>>
>> Martin Taal <mtaal@elver.org> wrote in
>> news:f312gj$deh$1@build.eclipse.org:
>>
>>> Hi Anthony,
>>> Just setting these two annotations:
>>> @Id
>>> @GeneratedValue
>>>
>>> results in a native id mapping in hbm.
>>> Btw, it can be handy to use an edatatype for the id eattributes and
>>> then set the annotation on the edatatype.
>>>
>>> gr. Martin
>>>
>>> Anthony wrote:
>>>> Hi Martin,
>>>>
>>>> when id column's generator set as native ,
>>>>
>>>> I should make the id get value from some sequence , right?
>>>>
>>>>
>>>> Anthony
>>>
>>
>
>
|
|
|
Re: [Teneo] id column get value from sequence [message #84572 is a reply to message #84566] |
Wed, 23 May 2007 15:02 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Anthony,
This can happen if the id of label has a non-null value (or a value which hibernate interprets as an
existing object). What is the id value of label?
gr. Martin
Anthony wrote:
> Martin,
>
> In Hibernate ActionQueue's prepareActions() ,
> the Label object is in collectionCreations ,but the
> ExecutableAction's persister(is a OneToManyPersister)'s
>
> sqlInsertRowString is "update ....."
>
> and
>
> sqlDeleteRowString also is "update..."
>
> no "insert..." or "delete ..."
>
> It seems some setting let hibernate think the Label should be exist in
> table.
>
>
>
> Anthony
>
>
>
>
>> My guess is that it expects that either network or label already exist
>> and it tries to update them instead of doing an insert. Can you debug
>> into hibernate and check which one is the cause?
>>
>> gr. Martin
>>
>> Anthony wrote:
>>> Martin,
>>>
>>> I have db table already , so I cannot update schema in runtime.
>>>
>>> I am using DB2 , I had set the primary key with Identity
>>> attribute. Now it is OK.
>>>
>>>
>>> 1 questions need your help:
>>>
>>>
>>>
>>> I create 1 Network object and 1 Label object,
>>> then I add Label object into Network object,
>>> then save().
>>>
>>> stacktrace :
>>> ============================================================ ======
>>> org.hibernate.StaleStateException: Batch update returned unexpected
>>> row count from update [0]; actual row count: 0; expected: 1
>>> at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatche d
>>> (Expectations.java:61)
>>> at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutco me
>>> (Expectations.java:46)
>>> at org.hibernate.jdbc.NonBatchingBatcher.addToBatch
>>> (NonBatchingBatcher.java:24)
>>> at org.hibernate.persister.entity.AbstractEntityPersister.updat e
>>> (AbstractEntityPersister.java:2403)
>>> at
>>> org.hibernate.persister.entity.AbstractEntityPersister.updat eOrInsert
>>> (AbstractEntityPersister.java:2307
>>> ============================================================ ===
>>>
>>> a fragment of mapping file as below:
>>> ============================================================ ==
>>> <class entity-name="LogisticsNetwork" abstract="false" lazy="false"
>>> table="SNOW.T_NETWORK1">
>>>
>>> <bag name="labels" lazy="false" cascade="all,delete-orphan">
>>> <key update="true">
>>> <column name="network_id" not-null="false"
>>>
>>> unique="false"/>
>>> </key>
>>> <one-to-many entity-name="Label"/>
>>> </bag>
>>>
>>> </class>
>>>
>>> <class entity-name="Label" abstract="false" lazy="false"
>>> table="SNOW.T_LABEL">
>>> <id name="id" type="int" column="label_id" >
>>> <generator class="native"/>
>>> </id>
>>> <property name="name" lazy="false" insert="true"
>>> update="true" not-null="true" unique="false" type="java.lang.String">
>>> <column not-null="true" unique="true"
>>> name="label_name"/>
>>> </property>
>>> <property name="typeValue" lazy="false" not-null="false"
>>> insert="true" update="true" unique="false" type="int">
>>> <column not-null="false" unique="false"
>>> name="label_type"/>
>>> </property>
>>> </class>
>>>
>>>
>>>
>>> How can I work around this?
>>>
>>>
>>>
>>>
>>>
>>>
>>> Reagrds,
>>> Anthony
>>>
>>>
>>>
>>> Martin Taal <mtaal@elver.org> wrote in
>>> news:f312gj$deh$1@build.eclipse.org:
>>>
>>>> Hi Anthony,
>>>> Just setting these two annotations:
>>>> @Id
>>>> @GeneratedValue
>>>>
>>>> results in a native id mapping in hbm.
>>>> Btw, it can be handy to use an edatatype for the id eattributes and
>>>> then set the annotation on the edatatype.
>>>>
>>>> gr. Martin
>>>>
>>>> Anthony wrote:
>>>>> Hi Martin,
>>>>>
>>>>> when id column's generator set as native ,
>>>>>
>>>>> I should make the id get value from some sequence , right?
>>>>>
>>>>>
>>>>> Anthony
>>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
| |
Re: [Teneo] id column get value from sequence [message #606770 is a reply to message #84548] |
Wed, 23 May 2007 09:56 |
Anthony Lee Messages: 114 Registered: July 2009 |
Senior Member |
|
|
Martin,
I have db table already , so I cannot update schema in runtime.
I am using DB2 , I had set the primary key with Identity attribute.
Now it is OK.
1 questions need your help:
I create 1 Network object and 1 Label object,
then I add Label object into Network object,
then save().
stacktrace :
============================================================ ======
org.hibernate.StaleStateException: Batch update returned unexpected row
count from update [0]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatche d
(Expectations.java:61)
at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutco me
(Expectations.java:46)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch
(NonBatchingBatcher.java:24)
at org.hibernate.persister.entity.AbstractEntityPersister.updat e
(AbstractEntityPersister.java:2403)
at org.hibernate.persister.entity.AbstractEntityPersister.updat eOrInsert
(AbstractEntityPersister.java:2307
============================================================ ===
a fragment of mapping file as below:
============================================================ ==
<class entity-name="LogisticsNetwork" abstract="false" lazy="false"
table="SNOW.T_NETWORK1">
<bag name="labels" lazy="false" cascade="all,delete-orphan">
<key update="true">
<column name="network_id" not-null="false"
unique="false"/>
</key>
<one-to-many entity-name="Label"/>
</bag>
</class>
<class entity-name="Label" abstract="false" lazy="false"
table="SNOW.T_LABEL">
<id name="id" type="int" column="label_id" >
<generator class="native"/>
</id>
<property name="name" lazy="false" insert="true"
update="true" not-null="true" unique="false" type="java.lang.String">
<column not-null="true" unique="true"
name="label_name"/>
</property>
<property name="typeValue" lazy="false" not-null="false"
insert="true" update="true" unique="false" type="int">
<column not-null="false" unique="false"
name="label_type"/>
</property>
</class>
How can I work around this?
Reagrds,
Anthony
Martin Taal <mtaal@elver.org> wrote in
news:f312gj$deh$1@build.eclipse.org:
> Hi Anthony,
> Just setting these two annotations:
> @Id
> @GeneratedValue
>
> results in a native id mapping in hbm.
> Btw, it can be handy to use an edatatype for the id eattributes and
> then set the annotation on the edatatype.
>
> gr. Martin
>
> Anthony wrote:
>> Hi Martin,
>>
>> when id column's generator set as native ,
>>
>> I should make the id get value from some sequence , right?
>>
>>
>> Anthony
>
>
|
|
|
Re: [Teneo] id column get value from sequence [message #606771 is a reply to message #84556] |
Wed, 23 May 2007 10:13 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
My guess is that it expects that either network or label already exist and it tries to update them
instead of doing an insert. Can you debug into hibernate and check which one is the cause?
gr. Martin
Anthony wrote:
> Martin,
>
> I have db table already , so I cannot update schema in runtime.
>
> I am using DB2 , I had set the primary key with Identity attribute.
> Now it is OK.
>
>
> 1 questions need your help:
>
>
>
> I create 1 Network object and 1 Label object,
> then I add Label object into Network object,
> then save().
>
> stacktrace :
> ============================================================ ======
> org.hibernate.StaleStateException: Batch update returned unexpected row
> count from update [0]; actual row count: 0; expected: 1
> at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatche d
> (Expectations.java:61)
> at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutco me
> (Expectations.java:46)
> at org.hibernate.jdbc.NonBatchingBatcher.addToBatch
> (NonBatchingBatcher.java:24)
> at org.hibernate.persister.entity.AbstractEntityPersister.updat e
> (AbstractEntityPersister.java:2403)
> at org.hibernate.persister.entity.AbstractEntityPersister.updat eOrInsert
> (AbstractEntityPersister.java:2307
> ============================================================ ===
>
> a fragment of mapping file as below:
> ============================================================ ==
> <class entity-name="LogisticsNetwork" abstract="false" lazy="false"
> table="SNOW.T_NETWORK1">
>
> <bag name="labels" lazy="false" cascade="all,delete-orphan">
> <key update="true">
> <column name="network_id" not-null="false"
> unique="false"/>
> </key>
> <one-to-many entity-name="Label"/>
> </bag>
>
> </class>
>
> <class entity-name="Label" abstract="false" lazy="false"
> table="SNOW.T_LABEL">
> <id name="id" type="int" column="label_id" >
> <generator class="native"/>
> </id>
> <property name="name" lazy="false" insert="true"
> update="true" not-null="true" unique="false" type="java.lang.String">
> <column not-null="true" unique="true"
> name="label_name"/>
> </property>
> <property name="typeValue" lazy="false" not-null="false"
> insert="true" update="true" unique="false" type="int">
> <column not-null="false" unique="false"
> name="label_type"/>
> </property>
> </class>
>
>
>
> How can I work around this?
>
>
>
>
>
>
> Reagrds,
> Anthony
>
>
>
> Martin Taal <mtaal@elver.org> wrote in
> news:f312gj$deh$1@build.eclipse.org:
>
>> Hi Anthony,
>> Just setting these two annotations:
>> @Id
>> @GeneratedValue
>>
>> results in a native id mapping in hbm.
>> Btw, it can be handy to use an edatatype for the id eattributes and
>> then set the annotation on the edatatype.
>>
>> gr. Martin
>>
>> Anthony wrote:
>>> Hi Martin,
>>>
>>> when id column's generator set as native ,
>>>
>>> I should make the id get value from some sequence , right?
>>>
>>>
>>> Anthony
>>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: [Teneo] id column get value from sequence [message #606772 is a reply to message #84560] |
Wed, 23 May 2007 11:25 |
Anthony Lee Messages: 114 Registered: July 2009 |
Senior Member |
|
|
Martin,
In Hibernate ActionQueue's prepareActions() ,
the Label object is in collectionCreations ,but the
ExecutableAction's persister(is a OneToManyPersister)'s
sqlInsertRowString is "update ....."
and
sqlDeleteRowString also is "update..."
no "insert..." or "delete ..."
It seems some setting let hibernate think the Label should be exist in
table.
Anthony
> My guess is that it expects that either network or label already exist
> and it tries to update them instead of doing an insert. Can you debug
> into hibernate and check which one is the cause?
>
> gr. Martin
>
> Anthony wrote:
>> Martin,
>>
>> I have db table already , so I cannot update schema in runtime.
>>
>> I am using DB2 , I had set the primary key with Identity
>> attribute. Now it is OK.
>>
>>
>> 1 questions need your help:
>>
>>
>>
>> I create 1 Network object and 1 Label object,
>> then I add Label object into Network object,
>> then save().
>>
>> stacktrace :
>> ============================================================ ======
>> org.hibernate.StaleStateException: Batch update returned unexpected
>> row count from update [0]; actual row count: 0; expected: 1
>> at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatche d
>> (Expectations.java:61)
>> at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutco me
>> (Expectations.java:46)
>> at org.hibernate.jdbc.NonBatchingBatcher.addToBatch
>> (NonBatchingBatcher.java:24)
>> at org.hibernate.persister.entity.AbstractEntityPersister.updat e
>> (AbstractEntityPersister.java:2403)
>> at
>> org.hibernate.persister.entity.AbstractEntityPersister.updat eOrInsert
>> (AbstractEntityPersister.java:2307
>> ============================================================ ===
>>
>> a fragment of mapping file as below:
>> ============================================================ ==
>> <class entity-name="LogisticsNetwork" abstract="false" lazy="false"
>> table="SNOW.T_NETWORK1">
>>
>> <bag name="labels" lazy="false" cascade="all,delete-orphan">
>> <key update="true">
>> <column name="network_id" not-null="false"
>>
>> unique="false"/>
>> </key>
>> <one-to-many entity-name="Label"/>
>> </bag>
>>
>> </class>
>>
>> <class entity-name="Label" abstract="false" lazy="false"
>> table="SNOW.T_LABEL">
>> <id name="id" type="int" column="label_id" >
>> <generator class="native"/>
>> </id>
>> <property name="name" lazy="false" insert="true"
>> update="true" not-null="true" unique="false" type="java.lang.String">
>> <column not-null="true" unique="true"
>> name="label_name"/>
>> </property>
>> <property name="typeValue" lazy="false" not-null="false"
>> insert="true" update="true" unique="false" type="int">
>> <column not-null="false" unique="false"
>> name="label_type"/>
>> </property>
>> </class>
>>
>>
>>
>> How can I work around this?
>>
>>
>>
>>
>>
>>
>> Reagrds,
>> Anthony
>>
>>
>>
>> Martin Taal <mtaal@elver.org> wrote in
>> news:f312gj$deh$1@build.eclipse.org:
>>
>>> Hi Anthony,
>>> Just setting these two annotations:
>>> @Id
>>> @GeneratedValue
>>>
>>> results in a native id mapping in hbm.
>>> Btw, it can be handy to use an edatatype for the id eattributes and
>>> then set the annotation on the edatatype.
>>>
>>> gr. Martin
>>>
>>> Anthony wrote:
>>>> Hi Martin,
>>>>
>>>> when id column's generator set as native ,
>>>>
>>>> I should make the id get value from some sequence , right?
>>>>
>>>>
>>>> Anthony
>>>
>>
>
>
|
|
|
Re: [Teneo] id column get value from sequence [message #606773 is a reply to message #84566] |
Wed, 23 May 2007 15:02 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Anthony,
This can happen if the id of label has a non-null value (or a value which hibernate interprets as an
existing object). What is the id value of label?
gr. Martin
Anthony wrote:
> Martin,
>
> In Hibernate ActionQueue's prepareActions() ,
> the Label object is in collectionCreations ,but the
> ExecutableAction's persister(is a OneToManyPersister)'s
>
> sqlInsertRowString is "update ....."
>
> and
>
> sqlDeleteRowString also is "update..."
>
> no "insert..." or "delete ..."
>
> It seems some setting let hibernate think the Label should be exist in
> table.
>
>
>
> Anthony
>
>
>
>
>> My guess is that it expects that either network or label already exist
>> and it tries to update them instead of doing an insert. Can you debug
>> into hibernate and check which one is the cause?
>>
>> gr. Martin
>>
>> Anthony wrote:
>>> Martin,
>>>
>>> I have db table already , so I cannot update schema in runtime.
>>>
>>> I am using DB2 , I had set the primary key with Identity
>>> attribute. Now it is OK.
>>>
>>>
>>> 1 questions need your help:
>>>
>>>
>>>
>>> I create 1 Network object and 1 Label object,
>>> then I add Label object into Network object,
>>> then save().
>>>
>>> stacktrace :
>>> ============================================================ ======
>>> org.hibernate.StaleStateException: Batch update returned unexpected
>>> row count from update [0]; actual row count: 0; expected: 1
>>> at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatche d
>>> (Expectations.java:61)
>>> at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutco me
>>> (Expectations.java:46)
>>> at org.hibernate.jdbc.NonBatchingBatcher.addToBatch
>>> (NonBatchingBatcher.java:24)
>>> at org.hibernate.persister.entity.AbstractEntityPersister.updat e
>>> (AbstractEntityPersister.java:2403)
>>> at
>>> org.hibernate.persister.entity.AbstractEntityPersister.updat eOrInsert
>>> (AbstractEntityPersister.java:2307
>>> ============================================================ ===
>>>
>>> a fragment of mapping file as below:
>>> ============================================================ ==
>>> <class entity-name="LogisticsNetwork" abstract="false" lazy="false"
>>> table="SNOW.T_NETWORK1">
>>>
>>> <bag name="labels" lazy="false" cascade="all,delete-orphan">
>>> <key update="true">
>>> <column name="network_id" not-null="false"
>>>
>>> unique="false"/>
>>> </key>
>>> <one-to-many entity-name="Label"/>
>>> </bag>
>>>
>>> </class>
>>>
>>> <class entity-name="Label" abstract="false" lazy="false"
>>> table="SNOW.T_LABEL">
>>> <id name="id" type="int" column="label_id" >
>>> <generator class="native"/>
>>> </id>
>>> <property name="name" lazy="false" insert="true"
>>> update="true" not-null="true" unique="false" type="java.lang.String">
>>> <column not-null="true" unique="true"
>>> name="label_name"/>
>>> </property>
>>> <property name="typeValue" lazy="false" not-null="false"
>>> insert="true" update="true" unique="false" type="int">
>>> <column not-null="false" unique="false"
>>> name="label_type"/>
>>> </property>
>>> </class>
>>>
>>>
>>>
>>> How can I work around this?
>>>
>>>
>>>
>>>
>>>
>>>
>>> Reagrds,
>>> Anthony
>>>
>>>
>>>
>>> Martin Taal <mtaal@elver.org> wrote in
>>> news:f312gj$deh$1@build.eclipse.org:
>>>
>>>> Hi Anthony,
>>>> Just setting these two annotations:
>>>> @Id
>>>> @GeneratedValue
>>>>
>>>> results in a native id mapping in hbm.
>>>> Btw, it can be handy to use an edatatype for the id eattributes and
>>>> then set the annotation on the edatatype.
>>>>
>>>> gr. Martin
>>>>
>>>> Anthony wrote:
>>>>> Hi Martin,
>>>>>
>>>>> when id column's generator set as native ,
>>>>>
>>>>> I should make the id get value from some sequence , right?
>>>>>
>>>>>
>>>>> Anthony
>>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Goto Forum:
Current Time: Thu Sep 19 23:32:41 GMT 2024
Powered by FUDForum. Page generated in 0.04774 seconds
|