ebean

Play framework, inserting initial-data more than 20 items per one Model

廉价感情. 提交于 2020-01-05 10:08:04
问题 In the development mode of Play framework, I inserted my initial-data.yml through Global.java. However, if one model has more than 20 items, autu-generated IDs is going crazy. For example, if I had: computers: - !!models.Computer name: apple01 - !!models.Computer name: apple02 - !!models.Computer name: apple03 - !!models.Computer name: apple04 ... - !!models.Computer name: apple20 - !!models.Computer name: apple21 - !!models.Computer name: apple22 From 1 to 20, they got correct auto-generated

Play framework, inserting initial-data more than 20 items per one Model

好久不见. 提交于 2020-01-05 10:07:08
问题 In the development mode of Play framework, I inserted my initial-data.yml through Global.java. However, if one model has more than 20 items, autu-generated IDs is going crazy. For example, if I had: computers: - !!models.Computer name: apple01 - !!models.Computer name: apple02 - !!models.Computer name: apple03 - !!models.Computer name: apple04 ... - !!models.Computer name: apple20 - !!models.Computer name: apple21 - !!models.Computer name: apple22 From 1 to 20, they got correct auto-generated

Ebeans where columnA equals columnB in same table

故事扮演 提交于 2020-01-04 13:48:05
问题 I have a table that, amongst other things, has two columns of type Long. In my query, i want to return rows where column A (type long) equals column B (type long). I would like to do this without writing raw sql, and instead use the much nicer method chaining. So far i've always had a value to compare the column against, which i can pass in, such as .eq("columnA", 5L) However, I can't seem to find any method for something like .eq("columnA", "columnB") I feel like this should be a fairly

Play Framework 2.4 Ebean Id Generation

99封情书 提交于 2020-01-02 06:57:22
问题 until now we have been using Play 2.3.9 and we are now migrating to Play 2.4.1 When I use the old version of Play saving an Entity works but with the new verion the Id is not generated. I setup a new project from scratch and tried it to realize it works and the auto generated database has an Id field that auto increments while the old project has a database that uses sequences. I have been trying to configure play/ebean to use sequences but have not been succesfull thus far. I took a look

Ebean: Cascade with OneToOne – tries inserts instead of update

眉间皱痕 提交于 2020-01-02 05:29:08
问题 I'm using Scala with Ebean, and I've run into some serious trouble. The situation is quite simple, I have a parent entity: @Entity case class Person(@(PrivateOwned@field) @(OneToOne@field)(fetch = FetchType.LAZY, cascade = Array(CascadeType.ALL), orphanRemoval = true) @(JoinColumn@field)(name = "website_setting_id") websiteSetting: WebsiteSetting, @(Id@field)id: Long = 0) extends Model where WebsiteSetting is: @Entity case class WebsiteSetting(@(Column@field)(unique = true) domain: String,

How do I enable Ebean Enhancement in Maven?

风流意气都作罢 提交于 2020-01-01 11:50:44
问题 I've been using Avaje.org ebean ORM layer for a while, but I don't understand how to enable the byte-code enhancement functionality described in the "Ebean v2.6.0 User Guide" with Maven. I found a configuration example on the Avaje.org homepage, but it doesn't work. Neither does the demo Maven boilerplate on GitHub. Help! 回答1: EBeans now has its own Maven Plugin, but I can't find any documentation online, so here is an example of how to use it: <plugin> <groupId>org.avaje.ebeanorm</groupId>

Duplicate columns when using EmbeddedId with a ManyToOne mapping with Ebean

耗尽温柔 提交于 2020-01-01 07:58:45
问题 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

How do I tell Play Framework 2 and Ebean to save null fields?

爱⌒轻易说出口 提交于 2020-01-01 02:39:11
问题 I'm using Play Framework 2 and Ebean. When a user submits a form to edit an existing object in the database, it doesn't save null values. I guess this is to prevent overwriting fields that aren't in the form with null. But how can I let them set fields in the form to null if they need to? For example, the user edits an Event object. Event.date is 1/1/13. The user sets the Event.date field in the form to empty and submits the form. Inspecting Event.date in the debugger shows its value is null.

Ebean EmbeddedId mapping column to ManyToOne relation

霸气de小男生 提交于 2019-12-30 11:12:35
问题 I'm facing a problem with Ebean when trying to create Composed Keys (EmbeddedId). This is a draft of what I have: @Entity public class EntityA extends Model{ @Id private String ID; @OneToMany private List<EntityB> listEntitesB; public EntityA(){ ID = UUID.randomUUID(); } } @Entity public class EntityB extends Model{ @EmbeddedId private EntityB_PK ID; @ManyToOne @JoinColumn(name="entityA_fk", referencedColumnName="listEntitiesB") private EntityA entityA; public EntityB(String entityB_ID){ ID =

Multiple Databases with Play Framework 2.1.x

女生的网名这么多〃 提交于 2019-12-29 21:10:57
问题 I have 2 databases that I need to connect to. I can easily connect to them in the application.conf file like so: db.default.driver=org.postgresql.Driver db.default.url="jdbc:postgresql://localhost/db1" db.default.user=postgres db.default.password="password" db.secondary.driver=org.postgresql.Driver db.secondary.url="jdbc:postgresql://localhost/db2" db.secondary.user=postgres db.secondary.password="password" ebean.default="models.db1.*" ebean.secondary="models.db2.*" I have my model classes in