Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1029217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:30:41+00:00 2026-05-16T12:30:41+00:00

I got a OneToMany relation between User and Group Group.java @Entity public class Group

  • 0

I got a OneToMany relation between User and Group
Group.java

@Entity
public class Group {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)        
private Long id;

private String groupid;

@ManyToOne
@JoinColumn(name="USER_FK")
private User user;
...
}

User.java

@Entity
public class User {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)    
private Long id;

private String userId;

private String password;

private String fname;

private String lname;

@OneToMany(mappedBy="user", cascade=CascadeType.ALL)
private List<Group> groups;

public void addGroup(Group group){
    if(this.groups == null){
        this.groups = new ArrayList<Group>();
    }
    this.groups.add(group);
    group.setUser(this);
}
}

So when I try to persist the object

    User user = em.find(User.class, 1L);
    user.addGroup(group);
    persist(user);

I got this

Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP (ID, GROUPID, USER_FK) VALUES (2501, 'fdsaf', 1)' at line 1
Error Code: 1064
Call: INSERT INTO GROUP (ID, GROUPID, USER_FK) VALUES (?, ?, ?)
bind => [2501, fdsaf, 1]
Query: InsertObjectQuery(org.xdrawings.entity.Group@a1c)

As you can see, it try to insert the correct values, but somehow it marked as syntax error. I think it missing single quote around GROUP, but since it does the query under the hood, I have no idea how to fix it. Note that I did the exact same thing to with other entity in the same project and it works fine. So frustrated !!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:30:42+00:00Added an answer on May 16, 2026 at 12:30 pm

    GROUP is indeed a reserved keyword, you’ll have to escape it. In JPA 2.0, there is a standardized way to specify delimited identifiers. From the JPA 2.0 specification:

    2.13 Naming of Database Objects

    …

    To specify delimited identifiers, one of the following approaches must be used:

    • It is possible to specify that all database identifiers in use for a persistence unit be treated as delimited identifiers by specifying the <delimited-identifiers/> element within the persistence-unit-defaults element of the object/relational xml mapping file. If the <delimited-identifiers/> element is specified, it cannot be overridden.
    • It is possible to specify on a per-name basis that a name for a database object is to be interpreted as a delimited identifier as follows:
      • Using annotations, a name is specified as a delimited identifier by enclosing the name
        within double quotes, whereby the inner quotes are escaped, e.g., @Table(name="\"customer\"").
      • When using XML, a name is specified as a delimited identifier by use of double
        quotes, e.g., <table name="&quot;customer&quot;"/>

    So something like this should work:

    @Entity
    @Table(name="\"GROUP\"")
    public class Group {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.