开发者

Java Hibernate id auto increment

Hy

I'v a little problem with hibernate on netbeans. I've a table with an Auto increment id :

CREATE TABLE "DVD"
(
    "DVD_ID" INT not null primary key
            GENERATED ALWAYS AS IDENTITY
            (START WITH 1, INCREMENT BY 1),
    "TITLE" VARCHAR(150),
    "COM" LONG VARCHAR,
 "COVER" VARCHAR(150) 

);

But this auto increment is not properly detected with Reverse Engineering. I get a map file with this :

<id name="dvdId" type="int">
    <column name="DVD_ID" />
    <generator class="assigned" />
</id>

i've looked on google and on this site ... foud some stuf but i'm still stuck..

i've tried to add insert="false" update="false" on the map file but i get back :

Caused by: org.xml.sax.SAXParseException: Attribute "insert" must be declared for element type "id".

Anny help will be pleas开发者_Go百科ed

Vincent


Change the generator class to "identity" if you want an auto-generated value from the database.


I'm not sure if I got you well but if you aren't using user input for "id" and you want it to autogenerate and autoincrement, then just change class="assigned" to class="increment".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜