This blog is mainly about Java...

Showing posts with label MyISAM. Show all posts
Showing posts with label MyISAM. Show all posts

Wednesday, May 7, 2008

Seam-gen problems when having MyISAM as engine in MySQL

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.

Labels