0
나는 세 가지 요소를 가지고있다. 각 사용자에는 팀이 있습니다. 각 사용자는 TeamInvite를 작성하여 자신의 팀 다른 사용자를 초대 할 수 있습니다. TeamInvite이 수락되면 각 사용자의 * 팀 *이 업데이트됩니다. TeamInvites은 사용자에게에만 영향을 미치며, 팀은입니다.재생! <em>사용자</em>, <em>팀</em> 및 <em>TeamInvite</em> : JPA @ManyToMany 버그
나는 야베 데모에서 내 주석 구조를 복사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)
...
(게시물 태그의 설정을 가지고) : TeamInvite.fulfill()
가 호출 될 때
@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();
}
}
, 나는 다음과 같은 오류가 발생합니다. 아무도 내가 뭘 잘못하고 있는지 알아?
Team.team을 Team.members (어쨌든 더 나은 이름 임)로 변경하면 실제로 문제가 해결되었습니다. 감사! –