ebean

how to enhance ebean models in a jar

烈酒焚心 提交于 2019-12-11 20:04:05
问题 i have this requirement to factor out the ebean models of a project so they can be reused by other play projects. i thought about creating a subproject containing only the models, but then that means i have to duplicate the subproject in every project that depends on it which isn't DRY enough to me. so then i created a jar of the subproject using publishLocal so the main project now just includes it like any other library in the build.sbt file. everything compiles well but when i run the main

How do I define multiple conditions on a join JPA/Ebean

≯℡__Kan透↙ 提交于 2019-12-11 12:18:07
问题 Ok, lets say I have order and items tables. This is how items are described in my Order class: @ManyToMany(cascade=CascadeType.PERSIST) @JoinTable(name="MY_ORDER_ITEM_BRIDGE", joinColumns=@JoinColumn(name="bridge_order_id",referencedColumnName = "order_order_id"), inverseJoinColumns = @JoinColumn(name="bridge_item_id", referencedColumnName="item_item_id")) private List<Item> items; This works fine. But lets image that there is a date in the bridge table called MY_ORDER_ITEM_BRIDGE.expiration

How to persist a collection of Strings in Play Framework 2.3.8?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 11:41:25
问题 I have such model: import play.db.ebean.Model; import javax.persistence.*; import java.util.*; @Entity public class Translation extends Model { @Id public Long id; @ElementCollection public Set<String> languages = new HashSet<>(); } When I compile and run, there are no languages in the database evolution. The database is PostgreSQL 9.3.6 on Heroku. I tried with List and ArrayList , but this didn't help. How to persist a collection of Strings in Play Framework 2.3.8? 回答1: It is not yet

Optional columns to filter dataBase records

匆匆过客 提交于 2019-12-11 11:14:35
问题 How should I use the finder of Ebean to create a query with optional columns to filter some data? I want to get a List<User> for instance. Imagine I have 3 columns to filter: by Name, by genre and something else. If I select the genre, the query should list all records of genre selected, after that, if I select name John and genre male, the query should List all "John" who are "male" and it's so on. I know to create simple querys to find for a column: find.where().eq("ex1",var1).eq("ex2",

Ebean multiple @ManyToMany delivers strange behavior

无人久伴 提交于 2019-12-11 08:46:57
问题 I experience strange behavior with Ebean (version 3.2.2), whenever I try to use multiple @ManyToMany attributes with CascadeType.ALL in a model. I've made a simplified example to reproduce the problem: I have the following two Entities (getters omitted) @Entity public class Foo extends Model { @Id @GeneratedValue private Long id; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "foo_bar1") private List<Bar> bars1; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "foo_bar2")

ManyToMany query using play and ebean

邮差的信 提交于 2019-12-11 07:08:57
问题 I'm trying to query using a finder with a ManyToMany relationship and have not been able to figure this out. Using play 2.1.2 and ebean 3.1.1 (packaged with Play). I have a MyUser class that has MyContacts, and MyContactGroups. MyContactGroups has a ManyToMany with MyContact. I'm trying to write a query where I can get all the MyContacts that are in a MyContactGroup for a MyUser. The query method below that fails is findByContactGroupAndUser. entities are: @Entity @Table(name = "my_user")

How do I find all records matching a list of Ids in ebean and play framework?

南楼画角 提交于 2019-12-11 06:20:00
问题 I have a model class that has an id per record. And I have a list of id's that I want to search from that table. Do I need to build a SQL statement dynamically and pass it to the Finder object or is there a better way of doing it? 回答1: Try to build a query using Expr.in(String propertyName, Collection<?> values) Other options are : Expr.in(String propertyName, Object[] values) or Expr.in(String propertyName, Query<?> subQuery) API reference. 来源: https://stackoverflow.com/questions/16387727

Error executing MySQL query via ebean using RawSql

喜你入骨 提交于 2019-12-11 05:52:51
问题 In a Play! 2.x application, I'm trying to send a simple query to a MySQL server using ebean. My complete class looks as follows: public static List<Venue> search(String query) { List<Venue> matches = new ArrayList<Venue>(); try { String q = query.replace(" ", ""); String sql = "SELECT v.id, c.company, c.postcode \n" + "FROM venue v \n" + "JOIN contact c ON (c.id = v.id) \n" + "WHERE REPLACE(c.postcode, ' ', '') LIKE '%" + q + "%' \n" + " OR c.company LIKE '%" + q + "%'"; RawSql rawSql =

Play 2.5 Ebean and JPA: NoSuchMethodError

*爱你&永不变心* 提交于 2019-12-11 04:54:47
问题 Yet another issue I'm experiencing while migrating my projects to Play 2.5. One of the projects uses both Ebean and JPA. Here is build.sbt: name := "Project" version := "1.0-SNAPSHOT" lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean) scalaVersion := "2.11.8" routesGenerator := StaticRoutesGenerator libraryDependencies ++= Seq( javaJdbc, javaJpa, "org.hibernate" % "hibernate-entitymanager" % "4.2.8.Final", cache, javaWs ) Everything was OK in Play 2.2.1. However, now I

Play! 2.0 Overwrite “Invalid Value” Message [duplicate]

人走茶凉 提交于 2019-12-11 02:25:36
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: What are the i18n message ids for field infos and errors? Using Annotations like @Required on a @Entity -class, a message attribute can be set easily. But how to set / overwrite the "Invalid value" message that is shown when a member of type Double is filled with a string on the form? The form.errors() -map contains an error with key "field name" and value "error.invalid", but I can't figure out the correct key