Why JPA refuses to persist Group objects
Problem
When working in Java using tools like JPA you sometimes forget to keep the limitations of the underlying database in mind. I spend about an hour trying to find out why my custom Group objects didn’t get persisted, and MySQL complained about incorrect SQL syntax.
Solution
When I tried to create a table for the group objects myself using a MySQL console it finally hit me… “Group” is a reserved word, and JPA does not handle the naming conflict. By adding a “name=” attribute to the Entity annotation I solved the conflict without renaming the object.
@Entity(name=”ClientGroup”)
public class Client implements Serializable {
….
Comments (0)
Trackbacks (0)
Leave a comment
Trackback