- This topic has 5 replies, 2 voices, and was last updated 19 years, 6 months ago by Riyad Kalla.
-
AuthorPosts
-
rbandeiraMemberHi to all,
I have a problem when i save an object. The type of the field is number(10) in oracle database and i send the object with no values in this property in class.
The result in data of the table is 2.E239 when the correct value should be 4.The trigger is okay.
In the XML mapping:
<id name=”id” column=”ID” type=”java.lang.Integer”>
<generator class=”sequence”>
<param name=”sequence”>SPEDIDO</param>
</generator>
</id>i had already tried with Long type with no success.
Any idea? 🙄
Thanks, Raphael!
Riyad KallaMemberand i send the object with no values in this property in class.
The result in data of the table is 2.E239 when the correct value should be 4.So the property value is null but when you persist the object you are saying that 2.E239 gets written in to the field?
If the field “SPEDIDO” is auto incrementing, then you can juust change the generator type to “native” and let the DB set the ID instead of having hibernate do it, I prefer this approach as the DB is just as good it not better at setting it’s own row IDs than Hibernate.
rbandeiraMemberOk! But if i want to use the sequence??? I dont want to write triggers in the database!! I would like to set the squence in the XML file and then let to hibernate to make the query with the “SPEDIDO.NEXTVAL()”…. 😕
I really cant think a way to this crazy number appears instead of “4”.
Maybe if i change the generator class from SEQUENCE to another type?
Thanks. Raphael! 😆
Riyad KallaMemberTry it, see what happens… if you are still getting this crazy number then there is some flaky code somewhere doing this. Try “native” (but the field type in the DB needs to be autoincrement).
rbandeiraMemberI understood, but i would like to use without auto-increment. My manager here dont like to put triggers in the DB to do that.
So, i must make with the sequence way…… please, help me!!!
Thanks, Raphael!! [img 😯 ]” alt=””>
Riyad KallaMemberAutoincrement is not a trigger, it’s a field type flag.
Regardless this is a Hibernate oddity, you are going to need to do some more investigation on your own before I can help, I have no idea what your server setup is like or what your project code looks like to help. This strange phantom number can be comming from anyone.
As far as troubleshooting, you can try creating a new very simple project that creates a mapping to your DB and try and write some test cases to see if it still generates these phantom values.
-
AuthorPosts