Home > Databases, Java > Why JPA refuses to persist Group objects

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 {
….

Advertisements
Categories: Databases, Java Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: