I tried running seam-gen on an existing MySQL database, where the engine is MyISAM.
Jboss-seam-2.0.1.GA is the version of seam I was running.
The strangest thing happened. When I reversed engineered the database to create entity beans, the foreign keys where not Objects like it is normally, but rather String.
For instance, in our Address entity bean, I have a foreign key that is mapped to the Country entity bean.
Normally the Address.java should look something like this:
@Entity
@Table(name = "address")
public class Address implements java.io.Serializable {
private Integer addressId; //The ID
private Country country; //The foreign key
....
}
However, the foreign key was generated like this:
private String countryId; //The foreign key
But when I changed the MySQL engine to use InnoDB instead, and I ran a new seam-gen, it was generated correctly.
Just a heads up if someone encounters the same problem. I would guess it is a bug in either seam or hibernate. Probably hibernate, since it is hibernate that does the generation.
This blog is mainly about Java...
Subscribe to:
Post Comments (Atom)
Labels
- Seam (14)
- Java (11)
- Hibernate (5)
- JPA (4)
- Seam 2 (4)
- Seam 2.1.1 (4)
- Seam Series (4)
- Devoxx (3)
- EJB3 (3)
- JavaOne (3)
- MySQL (3)
- PDF (3)
- jodconverter (3)
- jodconverter 3 (3)
- axis2 (2)
- hash password (2)
- pdfa (2)
- sigar (2)
- swing (2)
- testng (2)
- webservice (2)
- AngularJS (1)
- Cache (1)
- Comment (1)
- Dropwizard (1)
- Encryption (1)
- Enum (1)
- Freemarker (1)
- Guava (1)
- IE8 (1)
- IdentityManager (1)
- InnoDB (1)
- Iran (1)
- JOOReport (1)
- JSF (1)
- Jasypt (1)
- JavaPolis (1)
- Memory (1)
- MyISAM (1)
- ODT (1)
- OSS (1)
- OpenOffice (1)
- REST (1)
- Seam book (1)
- Tehran (1)
- UTF-8 (1)
- Ubuntu hardy (1)
- Windows vista (1)
- ant (1)
- chess (1)
- damenes tale (1)
- filters (1)
- firefox (1)
- html cache (1)
- interceptor (1)
- java 5 (1)
- java 6 (1)
- java 7 (1)
- javazone (1)
- javazone 2015 (1)
- jaxb (1)
- jboss (1)
- jboss 4 (1)
- jboss-ws (1)
- jdbc (1)
- jquery (1)
- jrebel (1)
- julebord (1)
- junit (1)
- musehÄnd (1)
- ojdbc (1)
- oracle (1)
- persistence.xml (1)
- prettify (1)
- ptql (1)
- richfaces (1)
- rollermouse pro (1)
- rpi (1)
- s:cache (1)
- seam-gen (1)
- second level cache (1)
- treecache (1)
- wicket (1)
4 comments:
It is not a bug. MySQL MyISAM engine doesn't support foreign keys but InnoDB does.
Well what do you know :-)
No wonder it didnt work then. Thank you for clarifying.
Friend,
I'm not able to generate my Seam project with proper foreign key implementation with Seam gen. I've tried everything and even though it's not working.
Can you please mail me a sample project generated by Seam gen where the database has foreign keys.
My email id is sanjayprogrammer@yahoo.co.in
Thanks.
Sanjay
You can always view the sample projects in seam. Instead, tell me what your problem is. What database are you using? As this blog post said, you cannot have MyISAM in MySQL. You should try INNODB.
Try "ALTER TABLE MYTABLE ENGINE=INNODB;"
Post a Comment