hibernate - Play! JPA @ManyToMany bug -
hibernate - Play! JPA @ManyToMany bug -
i have 3 entities: user, team, , teaminvite. each user has 1 team. each user can invite other users team creating teaminvite. when teaminvite accepted, each user's *team* updated. teaminvites not impact users, teams.
@entity public class team extends model { @onetoone public user user; @manytomany(cascade=cascadetype.all) //i've 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, next error:
persistenceexception occured : org.hibernate.exception.sqlgrammarexception: not insert collection: [models.team.team#2] play.exceptions.javaexecutionexception: org.hibernate.exception.sqlgrammarexception: not insert collection: [models.team.team#2] @ play.mvc.actioninvoker.invoke(actioninvoker.java:231) @ invocation.http request(play!) caused by: javax.persistence.persistenceexception: org.hibernate.exception.sqlgrammarexception: not insert collection: [models.team.team#2] @ org.hibernate.ejb.abstractentitymanagerimpl.convert(abstractentitymanagerimpl.java:1214) ... caused by: org.hibernate.exception.sqlgrammarexception: not insert collection: [models.team.team#2] @ org.hibernate.exception.sqlstateconverter.convert(sqlstateconverter.java:92) @ org.hibernate.exception.jdbcexceptionhelper.convert(jdbcexceptionhelper.java:66) @ org.hibernate.persister.collection.abstractcollectionpersister.recreate(abstractcollectionpersister.java:1243) @ org.hibernate.action.collectionupdateaction.execute(collectionupdateaction.java:81) ... caused by: org.h2.jdbc.jdbcsqlexception: duplicate column name "team_id"; sql statement: insert team_dp_user (team_id, team_id) values (?, ?) [42121-149] @ org.h2.message.dbexception.getjdbcsqlexception(dbexception.java:327) @ org.h2.message.dbexception.get(dbexception.java:167) ...
i copied annotation construction yabe demo (posts have set of tags). know i'm doing wrong?
i guess inverse side of team.team
relationship named user.team
well. if so, have collision between columns names in bring together table, because default form propertyname + "_id"
.
so, need alter 1 of property names, or override default column names @jointable
.
hibernate jpa playframework
Comments
Post a Comment