-
1. Re: Auto Increment problems
damianharvey.damianharvey.gmail.com Apr 26, 2008 9:16 PM (in response to pavera.pavera.gmail.com)And you've tried taking the field off of the form so that it is not submitted in the post?
As you've said, auto-incrementing fields are very common and is easily handled by Seam (well more by Hibernate/JPA).
Cheers,
Damian.
-
2. Re: Auto Increment problems
fernando_jmt Apr 27, 2008 1:54 AM (in response to pavera.pavera.gmail.com)Have you tried something like:
@Id @GeneratedValue(strategy=GenerationType.IDENTITY) privateLong id;
This works for me in mysql
autoincrement
columns.HTH.
-
3. Re: Auto Increment problems
pavera.pavera.gmail.com Apr 27, 2008 7:19 PM (in response to pavera.pavera.gmail.com)Yes, I took the fields in question out of the form, but they still submit 0, unless I add the @SequenceGenerator and @GeneratedValue annotations. This worked.
However, I then added 2 more tables to the DB and ran generate-entities again, and it overwrote all of my changes (and interestingly, duplicated the fields that were still on the forms, so now I have companyName twice, firstName twice, etc). How would one go about doing incremental development like this? Or does Seam expect the entire DB to be designed and implemented before you start on the code?
Is there a different script to run that will only add in the changes to the DB? Or to do incremental dev like this, do you just have to manually create the classes/views/etc?
As to the GenerationType.IDENTITY, that will not work in postgresql because PostgreSQL uses a sequence to populate the auto increment field. I guess I just kinda expected Seam (or hibernate/jpa) to do a better job at
discovering
the DB and coming up with sensible defaults for forms. -
4. Re: Auto Increment problems
zahidmaqbool Apr 30, 2008 5:54 AM (in response to pavera.pavera.gmail.com)This is how I have done in Oracle 10g and 9i
@Id @GeneratedValue(generator="afsStatus_Seq") @SequenceGenerator(name="afsStatus_Seq",sequenceName="AFSSTATUS_SEQUENCE", allocationSize=1) @Column(name="ID") public long getId() { return id; }
and this is how I have created my sequence:
CREATE SEQUENCE "MEWEUSER"."AFSSTATUS_SEQUENCE" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE ORDER NOCYCLE ;
-
5. Re: Auto Increment problems
baz Apr 30, 2008 8:23 AM (in response to pavera.pavera.gmail.com)You seem to have missed this post:
Form Builder