ebean

Error reading annotations with composite key in EBean

狂风中的少年 提交于 2019-12-23 04:14:26
问题 Following this link I would like to use OneToMany instead ManyToMany annotation, having middle class with composite key in it using Ebean. I have this error: java.lang.RuntimeException: Error reading annotations for models.SoftwareTagPk This is my SoftwareTagPk class: @Embeddable public class SoftwareTagPk implements Serializable { @ManyToOne private Tag tag; @ManyToOne private Software software; ... } And SoftwareTag class: @Entity public class SoftwareTag extends Model { @EmbeddedId private

(playframework 2.0.2-java) EBean - No ScalarType registered error when querying with enum values

人走茶凉 提交于 2019-12-23 02:44:24
问题 I have Role entity class: @Entity public class Role extends Model { @Id @Constraints.Required public Integer id; @Constraints.Required @Formats.NonEmpty @Enumerated(EnumType.STRING) public RoleNameEnum name; // name is enum value } In some test I try to find users by role: List<User> users = User.findByRole(Role.findByRoleName(RoleNameEnum.ADMIN)); where method findByRoleName() is following: public static List<User> findByRole(Role role) { return find.where().eq("role", role).findList(); } I

Using @OneToOne in PlayFramework 2 / Ebean ORM where the child and parent shares the same primary key

大兔子大兔子 提交于 2019-12-22 17:54:08
问题 There is two models: models/User.java @Entity @Table(name="users") public class User extends Model { @Id public int user_id; public String firstName; public String lastName; @OneToOne @PrimaryKeyJoinColumn public UserProfile profile; public static Finder<Integer,User> find = new Finder<Integer,User>( Integer.class, User.class ); } models/UserProfile.java @Entity @Table(name="user_profiles") public class UserProfile extends Model { @Id public int user_id; public String bio; @OneToOne(mappedBy

Using @OneToOne in PlayFramework 2 / Ebean ORM where the child and parent shares the same primary key

与世无争的帅哥 提交于 2019-12-22 17:53:01
问题 There is two models: models/User.java @Entity @Table(name="users") public class User extends Model { @Id public int user_id; public String firstName; public String lastName; @OneToOne @PrimaryKeyJoinColumn public UserProfile profile; public static Finder<Integer,User> find = new Finder<Integer,User>( Integer.class, User.class ); } models/UserProfile.java @Entity @Table(name="user_profiles") public class UserProfile extends Model { @Id public int user_id; public String bio; @OneToOne(mappedBy

Catch DB down exception in playframework

[亡魂溺海] 提交于 2019-12-22 13:11:13
问题 I want to handle DB errors when DB are down or not exists,to catch this error in order to make application not crashing and make application keep running even the DB down, error raise when DB is down: [error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection to jdbc:sqlite:db/dev.db Sleeping for 1000ms and trying again. Attempts left: 4. Exception: null.Message:path to 'db/dev.db': '/home/madian/workspace/mom/src/mom/db' does not exist 回答1: That Error you can handle in Global.java

Can't create composite primary key with foreign key in PLAY 2.0

对着背影说爱祢 提交于 2019-12-22 08:55:13
问题 This is a situation I want to represent in my PLAY project: table clients { client_id (pk), description } table items { client_id (fk, pk), item_id (pk) } In the 'items' table I want to have a composite primary key that will consist of combined client_id and item_id. I have read JPA documentation as well as many posts on the topic but everything fails again and again. This is one of many versions I have tried - closest to the JPA documentation. @Entity @Table(name = "items") public class

ebean unidirectional @OneToOne relation with unique constraint

北城以北 提交于 2019-12-22 05:57:31
问题 I have a User class: @Entity public class User extends Model { @Id public Long id; public String email; public String name; public String password; } and a driver class @Entity public class Driver extends Model { @Id public Long id; @OneToOne (cascade = CascadeType.ALL) @Column(unique = true) public User user; } I want to make sure that the user_id is unique inside the Drivers table. But the code above does not enforce that. (I can create multiple drivers with the same user id). Ideally, I do

Custom bridge table in playframework ebean

不羁岁月 提交于 2019-12-22 01:48:17
问题 I am unsuccessfuly trying to create bridge table that would resolve two @ManyToMany relations. However this table have to contain additional field. For example: Course: -course_id - pk Student: -student_id -pk Bridge: -(course_id, student_id) - pk -additional_field My student class looks like this: @Entity public class Student extends Model { @Id @OneToMany public List<Bridge> student_id; } Course class is basicaly the same. Bridge table looks like this: @Entity public class Bridge extends

java.lang.NoClassDefFoundError: sbt/compiler/IC$Result

久未见 提交于 2019-12-22 01:35:06
问题 Hope someone can help me to get rid of this issue. When I add addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0") to plugins.sbt then I get java.lang.NoClassDefFoundError: sbt/compiler/IC$Result plugins.sbt: logLevel := Level.Warn resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.3") addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0") build.sbt: name := "HelloWorld" version := "1.0"

Using Ebean/JPA in my Play application, how can I delete an object in a OneToOne relationship?

旧街凉风 提交于 2019-12-21 21:56:15
问题 I have the following classes: import play.db.ebean.Model; import javax.persistence.*; @Entity public class A extends Model { @Id private int id; /* Other irrelevant properties */ @OneToOne(cascade = CascadeType.ALL, optional = true) private B b; } import play.db.ebean.Model; import javax.persistence.*; @Entity public class B extends Model { @Id private int id; /* Other irrelevant properties */ @OneToOne(mappedBy = "b") private A a; @OneToOne(cascade = CascadeType.ALL, optional = false)