ebean

ebean unidirectional @OneToOne relation with unique constraint

寵の児 提交于 2019-12-05 10:13:21
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 not want to add the @OneToOne relations in the User class because there are several different roles

Cannot register class in Ebean server (Play Framework 2 - Java)

自闭症网瘾萝莉.ら 提交于 2019-12-05 04:22:50
I am getting the following error when running my Play Framework 2.2.x (Java) project: Configuration error Cannot register class [models.SomeClass] in Ebean server The error messages displayed in the browser points me to the line ebean.default="models.*" in my application.conf , and the console tells me that I have a java.lang.VerifyError: Bad type on operand stack in one of my methods. There is nothing special about the methods for which this happens, and it has happened for a handfull of methods now. I have found out that the error can be avoided by using a static method instead: that is by

How do I describe a bridge table to Ebean?

血红的双手。 提交于 2019-12-05 03:46:28
Lets say I have these tables: ORDER: id ITEM: id ORDER_ITEM: order_id, item_id The table: ORDER_ITEM is a bridge table between ORDER and ITEM . How do I describe this threesome to Ebean ? I would prefer not to use raw SQL so that I can still create and update these entities. UPDATE Sat Nov 9 02:32:40 UTC 2013 Ok, lets make this problem harder and more representative of my actual situation. The column names dont fit the convention: ORDER: order_number ITEM: item_number ORDER_ITEM: my_order, my_item You don't have to create special bridge table yourself unless you want to have other fields there

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

和自甴很熟 提交于 2019-12-04 20:47:37
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" lazy val `helloworld` = (project in file(".")).enablePlugins(PlayScala) scalaVersion := "2.11.7"

Play Framework - How to inherit from superclass?

本秂侑毒 提交于 2019-12-04 09:33:38
I have a User class, which extends Model, and two classes that I want to extend the User class. User.java: @Entity @Table(name = "users") public class User extends Model implements RoleHolder { private static final long serialVersionUID = 1L; @Id public Long id; ... Driver.java: public class Driver extends User { ... Customer.java: public class Customer extends User { ... Edit All three entities need to be directly accessed. To say it another way, I have Users, Customers, and Drivers; Customers and Drivers just happen to share all of the properties of a User. Therefore, I need to have a valid

Is it possible to use @PrePersist and @PreUpdate with eBean and Play! 2.0?

独自空忆成欢 提交于 2019-12-04 05:01:48
I want to know if is it possible to use @PrePersist and @PreUpdate with Ebean and Play! 2.0. If so how is this feature activated. I've seen that there was a pull request adding this feature a month ago, but I can't make this work on Play 2.0. Thanks If your goal is just setting createdAt or updatedAt fields, and you're using EBean, try @CreatedTimestamp and @UpdatedTimestamp . See here . I'd prefer to use Biesior's approach, but it seemed to fail on Cascades -- the methods were never called. @Column(name="created_at") @CreatedTimestamp private Date createdAt; @Column(name="updated_at")

How can I override Play's default Ebean server configuration?

别说谁变了你拦得住时间么 提交于 2019-12-04 04:03:41
I don't want to define the default database configuration in the application.conf file. Instead, I want to construct the default EbeanServer programmatically and inject it myself into the DAO. The problem I am having is, if I create a guice binding for a EbeanServer provider and not define any configuration in the application.conf file, play errors out saying it cannot find a default configuration. Here's the code I have: public class EbeanServerProvider implements Provider<EbeanServer> { final Logger.ALogger log = Logger.of(this.getClass()); @Override public EbeanServer get() { ServerConfig

Play Framework: Inheritance sort by type

試著忘記壹切 提交于 2019-12-04 02:24:11
问题 In my Application, I have 2 Classes: - Group - Model and one base class Element . I use the single table strategy to persist these models. (strategy = InheritanceType.SINGLE_TABLE) . Thus a column dtype is created in my table. I'm now trying to sort my pages based on this type: find.where().disjunction() .add(Expr.ilike("name", "%" + filter + "%")) .orderBy("dtype asc, name asc," + sortBy + " " + order).findList() But this throws an Exception, that dtype cannot be found. How can I sort based

Duplicate columns when using EmbeddedId with a ManyToOne mapping with Ebean

≡放荡痞女 提交于 2019-12-03 23:34:37
I have a model called "EventCheckin" which has a ManyToOne mapping to an "Event" and a "User". The PrimaryKey of the "EventCheckin" table is the id of the user and the id of the event. I'm trying to represent this using an "EmbeddedId" in my EventCheckin model but when I attempt to save an EventCheckin it tries to put the user_id and event_id values into the table twice which obviously fails: 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

How mature is Ebean or Siena? [closed]

谁说我不能喝 提交于 2019-12-03 09:33:06
Closed . This question is opinion-based. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . In the last time I heard a lot of complaining about hibernate. And indeed I have some painful experiences with hibernate too. So I read about Ebean and Siena . Both have interesting approaches. Unfortunately, database access layers are very easy to write, but if your project grows and you have to handle great database-tables, you know if they are good or not. So it's really difficult