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

  • Home
  • SEARCH
  • 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 7169039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:54:15+00:00 2026-05-28T14:54:15+00:00

I have three entities: User , Team , and TeamInvite . Each User has

  • 0

I have three entities: User, Team, and TeamInvite. Each User has one Team. Each User can invite other Users to their Team by creating a TeamInvite. When a TeamInvite is accepted, each User’s *Team* is updated. TeamInvites do not affect Users, just their Teams.

@Entity
public class Team extends Model {
    @OneToOne
    public User user;

    @ManyToMany(cascade=CascadeType.ALL)   //I've also tried CascadeType.PERSIST
    public List<User> team = new ArrayList<User>();
}

@Entity
public class TeamInvite extends Model {
    @ManyToOne
    public User inviter;

    @ManyToOne
    public User invitee;

    public void fulfill() {
        Team team = Team.forUser(inviter);
        team.team.add(invitee);
        team.save();    //error gets thrown here

        team = Team.forUser(invitee);
        team.team.add(inviter);
        team.save();

        delete();
    }
}

When TeamInvite.fulfill() gets called, I get the following error:

PersistenceException occured : org.hibernate.exception.SQLGrammarException: could not insert collection: [models.Team.team#2]

play.exceptions.JavaExecutionException: org.hibernate.exception.SQLGrammarException: could not insert collection: [models.Team.team#2]
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:231)
    at Invocation.HTTP Request(Play!)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not insert collection: [models.Team.team#2]
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214)
    ...
Caused by: org.hibernate.exception.SQLGrammarException: could not insert collection: [models.Team.team#2]
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1243)
    at org.hibernate.action.CollectionUpdateAction.execute(CollectionUpdateAction.java:81)
    ...
Caused by: org.h2.jdbc.JdbcSQLException: Duplicate column name "TEAM_ID"; SQL statement:
insert into Team_dp_user (Team_id, team_id) values (?, ?) [42121-149]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
    at org.h2.message.DbException.get(DbException.java:167)
    ...

I copied my annotation structure from the Yabe demo (Posts have a Set of Tags). Anybody know what I’m doing wrong?

  • 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-28T14:54:16+00:00Added an answer on May 28, 2026 at 2:54 pm

    I guess the inverse side of Team.team relationship is named User.team as well. If so, you have a collision between columns names in the join table, because their default form is propertyName + "_id".

    So, you need to change one of the property names, or override default column names with @JoinTable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three related entities: a user has many device a user has a
Suppose I have three entities. Department Task User User can publish some Task belonging
I have two entities User and Event. Each user has a list of events
I have three entities: User, Office and PhoneNumber. The user has many phone numbers,
I have a case where i have three entities with one-to-many and one-to-many relationships:
I have three entities that must interact: User , SupportTicket and PhoneConversation . When
Got three entities - User - Has username/password, contact information, billing information etc. Periodical
I have an entity ( TerminalCertification ) which has relation to other entities. I
I'm getting a list of 'team' entities where each 'team' entity has two foreign
I am working on a webapp that has three entities: User, Project, and Todo.

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.