小编InP*_*uit的帖子

使用带有Ebean的ManyToOne映射的EmbeddedId时重复列

我有一个名为"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)

jpa composite-key playframework ebean playframework-2.0

14
推荐指数
1
解决办法
5771
查看次数

将基于Play 2.1-SNAPSHOT的应用程序部署到Heroku

我有一个基于Play 2.1-SNAPSHOT的应用程序在本地运行良好,但当我尝试部署到Heroku时,我收到以下错误:

   [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
Run Code Online (Sandbox Code Playgroud)

属性.

我的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"错误之前,我看到以下警告:

   [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] ==== …
Run Code Online (Sandbox Code Playgroud)

heroku playframework

6
推荐指数
2
解决办法
1939
查看次数