ebean

(playframework 2.0.2-java) EBean - No ScalarType registered error when querying with enum values

*爱你&永不变心* 提交于 2019-12-06 16:56:09
I have Role entity class: @Entity public class Role extends Model { @Id @Constraints.Required public Integer id; @Constraints.Required @Formats.NonEmpty @Enumerated(EnumType.STRING) public RoleNameEnum name; // name is enum value } In some test I try to find users by role: List<User> users = User.findByRole(Role.findByRoleName(RoleNameEnum.ADMIN)); where method findByRoleName() is following: public static List<User> findByRole(Role role) { return find.where().eq("role", role).findList(); } I receive error: [error] Test UserTest.findUsersByRole failed: No ScalarType registered for class models

Catch DB down exception in playframework

穿精又带淫゛_ 提交于 2019-12-06 13:38:05
I want to handle DB errors when DB are down or not exists,to catch this error in order to make application not crashing and make application keep running even the DB down, error raise when DB is down: [error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection to jdbc:sqlite:db/dev.db Sleeping for 1000ms and trying again. Attempts left: 4. Exception: null.Message:path to 'db/dev.db': '/home/madian/workspace/mom/src/mom/db' does not exist That Error you can handle in Global.java file in app folder put a file which Global.java in app folder like this Global.java file import play

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

女生的网名这么多〃 提交于 2019-12-06 00:42:12
问题 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> {

DdlGenerator constructor needs no arguments?

会有一股神秘感。 提交于 2019-12-06 00:02:57
I wanted to unit test my database operation and I found this code . However, I get the followin error: [CityGame] $ test [info] Compiling 2 Java sources to /Users/pmichna/Documents/code/citygame/target/scala-2.10/test-classes... [error] /Users/pmichna/Documents/code/citygame/test/models/BaseModelTest.java:31: error: constructor DdlGenerator in class DdlGenerator cannot be applied to given types; [error] ddl = new DdlGenerator((SpiEbeanServer) server, new MySqlPlatform(), config); [error] ^ [error] required: no arguments [error] found: SpiEbeanServer,MySqlPlatform,ServerConfig [error] reason:

Play Framework 2.4 Ebean Id Generation

送分小仙女□ 提交于 2019-12-05 21:13:51
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 here http://www.avaje.org/topic-97.html and gave it a try but its still not working. Any suggestions would

manytomany relation not able to save mapped id in mapping table in play framework

半腔热情 提交于 2019-12-05 21:01:21
I am using play2.2.1 and trying to create a ManyToMany relation between Jobads and JobCategory models. My Jobads.java package models; @Entity public class Jobads extends Model { @Id public Long id; @ManyToOne public Employers employer; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "jobads_jobcategories") public List<Jobcategories> jobcategory; @ManyToOne public Joblocations joblocations; @Required public String jobtype; @Required public String title; @Required public String text; @Required public Long salary; @Required public String experience; @Required public String active;

Can't create composite primary key with foreign key in PLAY 2.0

女生的网名这么多〃 提交于 2019-12-05 17:04:17
This is a situation I want to represent in my PLAY project: table clients { client_id (pk), description } table items { client_id (fk, pk), item_id (pk) } In the 'items' table I want to have a composite primary key that will consist of combined client_id and item_id. I have read JPA documentation as well as many posts on the topic but everything fails again and again. This is one of many versions I have tried - closest to the JPA documentation. @Entity @Table(name = "items") public class Items extends Model { ItemsPK primaryKey; public Items() { } @EmbeddedId public ItemsPK getPrimaryKey() {

Play framework 2.3.x Server Error Cannot register class

依然范特西╮ 提交于 2019-12-05 16:51:35
I recently uploaded Play application on server. Problem is that I can ran application through command activator run it compiles and runs fine. When I try to do activator clean stage it also compiles but after target/universal/stage/bin/name_of_myapp it throws an error like Oops, cannot start the server. Configuration error: Configuration error[Cannot register class [models.Movie] in Ebean server] at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:94) at play.api.Configuration.reportError(Configuration.scala:743) at play.Configuration.reportError(Configuration

play.db package not found in play 2.1.3

爷,独闯天下 提交于 2019-12-05 11:23:37
Im trying to follow the play framework ebean tutorial here: http://www.playframework.com/documentation/2.1.2/JavaEbean However when I try to include play.db.ebean.* and try to compile, the package is not found (no play.db package). I have added ebean.default="models.*" to my application.conf Is there anything else I need to do to get the dependency? Is there an equivalent to play deps from play 1.2 for example? The trace: [error] /home/nfv/workspace-scala/scims/app/models/Person.scala:3: object db is not a member of package play [error] import play.db.ebean.Model; [error] ^ [error] /home/nfv

Play Framework: Error getting sequence nextval using H2 in-memory database

心不动则不痛 提交于 2019-12-05 10:31:21
As the title suggests, I get an error running Play 2.0.1 Tests using a FakeApplication w/ H2 in memory. I set up a basic unit test: public class ModelTest { @Test public void checkThatIndustriesExist() { running(fakeApplication(inMemoryDatabase()), new Runnable() { public void run() { Industry industry = new Industry(); industry.name = "Some name"; industry.shortname = "some-name"; industry.save(); assertThat(Industry.find.all()).hasSize(1); } }); } Which yields the following exception: [info] test.ModelTest [error] Test test.ModelTest.checkThatIndustriesExist failed: Error getting sequence