-
1. Re: ID GeneratedValue with Oracle Sequence
sebastiendeg.sebastien.degardin.gmail.com Feb 22, 2008 1:47 AM (in response to echen1)Hi,
You should give us more info, post your id generation config (annotation/xml) and give us the SQL error you have.
An entity with an Id generated by a database sequence will look like :
@Id @GeneratedValue(strategy = GenerationType.SEQUENCE)
If there is no generator named, the JPA Provider uses a default one.
One option is to define a sequence generator and then reference it in the @GeneratedValue annotation like.
@SequenceGenerator(name = "YouGenerator", sequenceName ="YouSequence")
This, of course expect you have a defined sequence in the database.
(it can also be generated, which isn't your case I think). -
2. Re: ID GeneratedValue with Oracle Sequence
echen1 Feb 22, 2008 5:01 PM (in response to echen1)Thank you Sabastien for your quick response.
I have since deleted the session classes as well as web files and recreated them using New Generate Entity with existing Entities. The code are working correctly now.
I still need some help in the following areas:
1. Can you recommend good reading materials to help understand how all pieces working together, Eclipse, Jboss Development Tool, Jboss AS, as well as Seam?
2. Modifications to the generated code do not appear to take effect consistently. What is the procedure to make code change and to verify that it gets deployed properly? I currently delete the ear file in JBoss AS's default deploy folder so it gets recreated, but sometimes I get an application.xml file does not exist error. I then exit and rerun Eclipse a few times until it runs correctly.
3. What is the creators' vision to develop an application. It is a great idea that Seam auto create generic code, and then developer make necessary adjustments. Should I make the necessary change to entity classes first and then regenerate the other codes? Is there an GUI way or recommended process to make changes?
4. Is there any example code to test the entity and Home beans?
5. Four projects get created for an EAR deployment. What is the recommended method to grow the application? Create new packages or to create other linked projects? How do we link to other Seam Ear projects as well as old projects? What's the best way to share the menu and security?
6. What is the purpose of the xml files? they are not created by the seam setup from the command line.Any help is greatly appreciated. Thank you in advance for your response.
-
3. Re: ID GeneratedValue with Oracle Sequence
sebastiendeg.sebastien.degardin.gmail.com Feb 22, 2008 6:03 PM (in response to echen1)
1. Can you recommend good reading materials to help understand how all pieces working together, Eclipse, Jboss Development Tool, Jboss AS, as well as Seam?For JSF, EJB and Seam,
A good understanding of EJB 3.0, JSF API and Seam is a starting point.
My point of view is that for enterprise application, you should have a complete understanding of Services like, Transaction (propagation, persistence context (extended, transaction-scoped and application scoped), and others primary services provided by the container (Seam and EJB)).
If you understand those API's then you can better understand how Seam integrate them altogether .
Cheers,
-
4. Re: ID GeneratedValue with Oracle Sequence
echen1 Feb 22, 2008 6:18 PM (in response to echen1)I have some basic understanding of EJB3, JSF, and JPA through a training class. What I am looking for is a lazy way to develop applications, or at least develop the code at a very high level. Seam fits in beautifully with the code gen capability. So, I am hoping to see some documentation on a cookie cutter way to modify the generated code at a higher level so that I do not have to know all the detailed API and syntax, etc.
Thanks again for your comments.
-
5. Re: ID GeneratedValue with Oracle Sequence
siew_edward Apr 22, 2008 6:09 PM (in response to echen1)Hi,
I am using Seam 2.0.2CR with Oracle XE sequence to generate the primary key for table A and B. Table A is a parent to Table B with one-to-many relationship. Table B has the primary key of Table A.
The problem is when Seam creates a new entry in Table A, it queries the sequence for a primary key. My debugging results show that the primary key insert into Table A (sequence from Oracle) is not the same as the foreign key inserted into Table B resulting the ORA-02291 integrity constraint violation - parent key not found exception. It seems that the value of the foreign key inserted into Table B is a random key generated by SEAM. Any idea why this is happening?
I've tried to apply the
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
for the A variable in B. But it doesn't refresh the values of A in B. Any idea?