我有一个名为"EventCheckin"的模型,它具有到"事件"和"用户"的ManyToOne映射."EventCheckin"表的PrimaryKey是用户的id和事件的id.我试图在我的EventCheckin模型中使用"EmbeddedId"来表示这一点,但是当我尝试保存EventCheckin时,它会尝试将user_id和event_id值放入表中两次,这显然会失败:
Caused by: org.h2.jdbc.JdbcSQLException: Duplicate column name "USER_ID"; SQL statement:
insert into eventCheckin (event_id, user_id, latitude, longitude, user_id, event
_id) values (?,?,?,?,?,?) [42121-158]
Run Code Online (Sandbox Code Playgroud)
EventCheckin课程:
@Entity
@Table(name="eventCheckin")
public class EventCheckin extends Model
{
@EmbeddedId public CheckinId id;
@MapsId("userId")
@JoinColumn(name="user_id")
@ManyToOne public User user;
@MapsId("eventId")
@JoinColumn(name="event_id")
@ManyToOne public Event event;
.....
}
Run Code Online (Sandbox Code Playgroud)
CheckinId EmbeddedId类::
@Embeddable
public class CheckinId implements Serializable
{
public Long eventId;
public String userId;
.....
}
Run Code Online (Sandbox Code Playgroud)
我的EventCheckin数据库表定义如下:
create table eventCheckin (
user_id varchar(255) not null,
event_id bigint not null, …Run Code Online (Sandbox Code Playgroud) 我有一个基于Play 2.1-SNAPSHOT的应用程序在本地运行良好,但当我尝试部署到Heroku时,我收到以下错误:
Run Code Online (Sandbox Code Playgroud)[warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: UNRESOLVED DEPENDENCIES :: [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: play#sbt-plugin;2.1-SNAPSHOT: not found [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] [warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested属性.
我的plugins.sbt文件指向包含2.1-SNAPSHOT依赖项的本地存储库:
resolvers ++= Seq(
"Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
Resolver.file("My Repository", file( "repository/local") )
)
// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1-SNAPSHOT")
Run Code Online (Sandbox Code Playgroud)
目录"repository/local"被检入我的GIT存储库.看起来像Heroku上的SBT正在寻找本地存储库,因为在"Unresolved Dependency"错误之前,我看到以下警告:
Run Code Online (Sandbox Code Playgroud)[warn] ==== Typesafe repository: tried [warn] http://repo.typesafe.com/typesafe/releases/play/sbt-plugin_2.9.1_0.11.2/2.1-SNAPSHOT/sbt-plugin-2.1-SNAPSHOT.pom [warn] ==== My Repository: tried [warn] ==== …