ebean

How to map Results when Querying raw SQL using Ebean

让人想犯罪 __ 提交于 2019-12-21 20:43:15
问题 Using Postgres Tables created by Ebean, I would like to query these tables with a hand-written statement: SELECT r.name, r.value, p.name as param1, a.name as att1, p2.name as param2, a2.name as att2 FROM compatibility c JOIN attribute a ON c.att1_id = a.id JOIN attribute a2 ON c.att2_id = a2.id JOIN PARAMETER p ON a.parameter_id = p.id JOIN PARAMETER p2 ON a2.parameter_id = p2.id JOIN rating r ON c.rating_id = r.id WHERE p.problem_id = %d OR p2.problem_id = %d Each of the joined tables

How to map Results when Querying raw SQL using Ebean

落爺英雄遲暮 提交于 2019-12-21 20:41:17
问题 Using Postgres Tables created by Ebean, I would like to query these tables with a hand-written statement: SELECT r.name, r.value, p.name as param1, a.name as att1, p2.name as param2, a2.name as att2 FROM compatibility c JOIN attribute a ON c.att1_id = a.id JOIN attribute a2 ON c.att2_id = a2.id JOIN PARAMETER p ON a.parameter_id = p.id JOIN PARAMETER p2 ON a2.parameter_id = p2.id JOIN rating r ON c.rating_id = r.id WHERE p.problem_id = %d OR p2.problem_id = %d Each of the joined tables

Play Framework - How to inherit from superclass?

a 夏天 提交于 2019-12-21 19:39:31
问题 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;

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

不想你离开。 提交于 2019-12-21 12:28:59
问题 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 回答1: 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

Ebean Query by OneToMany Relationship

牧云@^-^@ 提交于 2019-12-18 17:26:38
问题 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

Steps needed to use MySQL database with Play framework 2.0

天大地大妈咪最大 提交于 2019-12-17 05:34:08
问题 I'm new to Play framework. I'm trying to configure MySQL database as a datasource to be used with Play Ebeans. Could you some one please explain the steps that are needed to configure MySQL with Play 2.0 framework (like, downloading drivers, adding dependency etc). 回答1: Look at this page from Play's documentation. It says: Other than for the h2 in-memory database, useful mostly in development mode, Play 2.0 does not provide any database drivers. Consequently, to deploy in production you will

PersistenceException: ERROR executing DML bindLog when Updating an Object

﹥>﹥吖頭↗ 提交于 2019-12-14 04:06:08
问题 Good day! I have two objects: Tag and RelatedTag . The Tag can have many RelatedTag s (which is also a Tag ). Saving the Tag with its related tags works fine. But when I update the Tag , it has an error saying [PersistenceException: ERROR executing DML bindLog[] error[Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.RELATED_TAG(ID)"; SQL statement:\n insert into related_tag (id, tag_id, relationship, related_notes) values (?,?,?,?) [23505-172]]] Here is Tag model: package models;

PersistenceException, Column 'id' specified twice

。_饼干妹妹 提交于 2019-12-13 08:01:41
问题 I have the following files in Play Framework 2.2.3 Controller: public class Comment extends Controller { public Result create(UUID id) { models.blog.Blog blog = models.blog.Blog.finder.byId(id); Result result; if(blog == null) { result = notFound(main.render("404", error404.render())); } else { Form<models.blog.Comment> commentForm = Form.form(models.blog.Comment.class); commentForm = commentForm.bindFromRequest(); if(commentForm.hasErrors()) { result = badRequest(Json.toJson(commentForm)); }

How to save through a list into the Database, using play Framework ebean?

北城以北 提交于 2019-12-13 07:45:03
问题 I'm trying to save through a list of subheads but with the same Department Id but different subheadDepartmentID. How do i Go about it? subHeadDepartment.department= department; for(String thissubhead: ConstructedList){ SubHead subHead = SubHead.retrievebyName(thissubhead); subHeadDepartment.subhead=subHead; subHeadDepartment.save(); } The code I have here is updating just the first subheadDepartment Id in the loop.While what i want is to create a subheaddepartmentId for each subhead entered

Ebean Finder joins @OneToMany fields in a strange way (4 results instead of 2)

痞子三分冷 提交于 2019-12-13 06:01:34
问题 I have a method in my Model class which queries DB with the help of Finder: public static List<Bet> getBetsByUser(User user){ System.out.println("ROW COUNT: "+ find.fetch("user") .fetch("moneyPoolEntity.account") .fetch("coupon.moneyPoolEntities.account") .fetch("moneyPoolEntity.bettingTable") .fetch("moneyPoolEntity.moneyPoolType.currency").setDistinct(true) .where().eq("user", user).findRowCount() ); List<Bet> betList = find.fetch("user") .fetch("moneyPoolEntity.account") .fetch("coupon