ebean

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

[亡魂溺海] 提交于 2019-12-03 05:54:58
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. I save the Event . If I look at the Event in the database, its value is still 1/1/13. Edit: It seems

Avaje - EBean - Partial Object Query disable Lazy Loading

冷暖自知 提交于 2019-12-02 04:05:16
问题 I'm developing an app using Play! Framework 2.1.3, using EBean for the model layer I wanna be able to execute a Partial Object Query and not have the un-selected properties lazy loaded on demand when I serialize to JSON in preparation to send the result back to the user. I have tried setting AutoFetch to false, I have also tried to end the transaction before serializing to JSON (I ended up getting a Transaction is Inactive error) I've also added the annotation @Lazy(false) on my model class.

playframework - package javax.persistence does not exist

允我心安 提交于 2019-12-02 01:09:42
问题 I have Issue with using database I was going with this tutorial http://vimeo.com/58969923# (one from playframework.com page) in the model: play-2.2.1/jcirs/app/models/MedicalIncident.java public class MedicalIncident extends Model{} I am trying to use Entity. For that I have to import: javax.persistence.* and play.db.ebean.* but none of them can be found. The error is package javax.persistence does not exist What should I do? Use any other database engine? Or should download some dependency.

Avaje - EBean - Partial Object Query disable Lazy Loading

自闭症网瘾萝莉.ら 提交于 2019-12-02 00:45:13
I'm developing an app using Play! Framework 2.1.3, using EBean for the model layer I wanna be able to execute a Partial Object Query and not have the un-selected properties lazy loaded on demand when I serialize to JSON in preparation to send the result back to the user. I have tried setting AutoFetch to false, I have also tried to end the transaction before serializing to JSON (I ended up getting a Transaction is Inactive error) I've also added the annotation @Lazy(false) on my model class. On the same note, I also have a One-to-Many association, and I wanna Query the first 3 rows of it, I

playframework - package javax.persistence does not exist

穿精又带淫゛_ 提交于 2019-12-01 21:39:00
I have Issue with using database I was going with this tutorial http://vimeo.com/58969923# (one from playframework.com page) in the model: play-2.2.1/jcirs/app/models/MedicalIncident.java public class MedicalIncident extends Model{} I am trying to use Entity. For that I have to import: javax.persistence.* and play.db.ebean.* but none of them can be found. The error is package javax.persistence does not exist What should I do? Use any other database engine? Or should download some dependency. I would like to go with playframework best way. Please help. My configuration application.conf: db

[PersistenceException: Error getting sequence nextval]

不想你离开。 提交于 2019-12-01 18:18:50
i am getting this error while trying to save data into model in db. @Entity public class User extends Model { @Required public String name; @Email public String email; @Required @MaxLength(value=10) public String username; @Required @MinLength(value=4) public String password; @Id public int id; } this is my Class. this is the error while i am trying to save the model into db. i will appreciate any effort for help! many thanks. EDIT: table structure is here I think with ebean you have to physically name and annotate your id. You may also have to tell it the name of the backing sequencer as well

[PersistenceException: Error getting sequence nextval]

早过忘川 提交于 2019-12-01 17:31:07
问题 i am getting this error while trying to save data into model in db. @Entity public class User extends Model { @Required public String name; @Email public String email; @Required @MaxLength(value=10) public String username; @Required @MinLength(value=4) public String password; @Id public int id; } this is my Class. this is the error while i am trying to save the model into db. i will appreciate any effort for help! many thanks. EDIT: table structure is here 回答1: I think with ebean you have to

Play Framework: Inheritance sort by type

ぐ巨炮叔叔 提交于 2019-12-01 14:29:39
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 on the type? Thanks! Sample base model can look like: package models.db; import play.db.ebean.Model;

Ebean ManyToMany query

江枫思渺然 提交于 2019-11-30 19:13:47
I have two classes, user and car. Both have ManyToMany mapping to each other. User: @Entity public class User extends Model { private int year; @ManyToMany(cascade=CascadeType.ALL) private List<Car> cars; } Car: @Entity public class Car extends Model { @ManyToMany(mappedBy = "cars", cascade=CascadeType.ALL ) private List<User> users; } Using ebean, I would like to query only those cars from year 1999 that have give user in their list. I do not want to iterate over the user's car list in Java code. I didn't find any documentation how many-to-many queries should look like. So I would something

Ebean Query by OneToMany Relationship

早过忘川 提交于 2019-11-30 14:39:02
I'm using Ebean with the Play 2 Framework and got two models: a user model and a book model. The user model is connected with the book model in a OneToMany Relationship. So every user can have many books or no book at all. The book model itself has properties too. Now I want to create a query in the user model, which returns only users, who have books with certain properties. For example: One property might be condition, like new or used. Now give me all users which have books in new condition. Is it possible to create such a query with the Ebean methods? Or do I have to use raw SQL? Say you