ebean

How to create custom INSERT INTO query in Ebean?

老子叫甜甜 提交于 2019-12-28 04:14:10
问题 I need to fill a table with large amount of data so I don't want to find related objects, but just put numeric values of them. For this I'd build a simple query ie: INSERT INTO article_category (article_id, category_id) VALUES (2,12); anyway can't find a way to do this with Ebean, I was trying: RawSql rawSql = RawSqlBuilder .parse("INSERT INTO article_category (article_id, category_id) VALUES (2,12)") .create(); however that throws an exception: [RuntimeException: Error parsing sql, can not

再论 IoC 和 AOP

拈花ヽ惹草 提交于 2019-12-26 08:09:11
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 谈谈我对 IoC 和 AOP 的理解 一文由 JFinal 作者波总对 IoC 与 AOP 的一句表述引起: IOC 本质是为了实现 AOP 在文中我考察了 IoC , DI 和 AOP 三个概念及其关系, 并得出以下结论: IoC 的本质不是为了实现 AOP. 波总的 JFinal 已经实现了 IoC 原则. 因为应用写的代码总是被 JFinal 的代码调用, 这就是控制反转. DI 也不是为了实现 AOP @yong9981 对此文给出了以下评论: 我不赞同 yong9981 在评论中的观点, 所以在本文中一一回应. 1. " 其实不能算错, 相反,只有对IOC/AOP有深切理解的人才能说出这句话 " yong9981 这句话应该是针对波总的表述 " IoC 的本质是为了实现 AOP " 而言. 我在 谈谈 一文中已经清楚地给出了维基百科中对 IoC 和 AOP 这两个概念的描述, 并由此得到结论: " IoC 不是为了 AOP ". 如果 yong9981 认为波总的表述没有错误, 那就是我的结论有误. 逻辑上讲有两个可能: 维基百科对 IoC 和 AOP 的概念描述有错误 我在文中依据概念得出结论的过程不正确, 依据维基百科的概念描述应该得到 " IoC 的本质是为了实现 AOP " 这个表述 请

Play Framework Ebean two ManyToMany relations return same data

流过昼夜 提交于 2019-12-24 13:42:36
问题 My code looks like this: @Entity public class Document extends Model { @Id private Long id; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "developers") private Set<Tester> developers = new HashSet<>(); @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "testers") private Set<Tester> testers = new HashSet<>(); } I am using the JoinTable annotation otherwise I end up with the same join table for the many-to-many relation. This works well and I get two tables generated

foreign key query play! framework 2.+ ebean

倾然丶 夕夏残阳落幕 提交于 2019-12-24 04:47:07
问题 I'm new to play framework and the Ebean ORM. Basically, I have two models one is a RegUsers the other is RegIds . In my registration Ids I put a many to one relationship on the Field RegUsers . Stating, if I'm not mistaken that one user can have many registration ids. RegId model: @Entity public class RegId extends Model{ public static Finder<Long,RegId> finder = new Finder<Long,RegId>(Long.class, RegId.class); @Id public Long id; @ManyToOne public RegUsers regUsers; public String regId; }

PlayFramework, how to register a BeanPersistListener?

≯℡__Kan透↙ 提交于 2019-12-24 03:39:23
问题 I discovered the BeanPersistListener that I'd like to register to some of my models, but I didn't find any documentation, from Ebean nor PlayFramework on how to integrate it. From the documentation : A BeanPersistListener is either found automatically via class path search or can be added programmatically via ServerConfiguration.addEntity(). Apparently, it isn't found automatically (I added some Logger.info in the implemented methods, and nothing was shown), so I'd like to add it via

EntityNotFoundException: Bean has been deleted - lazy loading failed

空扰寡人 提交于 2019-12-23 13:13:43
问题 I'm making my first steps with the Play! Framework (v2.1-rc1) with Java and now I've faced my first problem with ebean. I have a navigation entity with a ManyToOne relationship to itself. As soon as I try to access the title field in a parentNavigation, I get the following error: [EntityNotFoundException: Bean has been deleted - lazy loading failed] As I found out, the error only appears if the parent navigation does not exist in the database. Shouldn't I receive an empty navigation object in

How to populate a ManyToMany relationship using YAML on Play Framework 2.1.x

情到浓时终转凉″ 提交于 2019-12-23 12:54:40
问题 I have the following ManyToMany (bidirectional) relationship: @Entity public class Proposal extends Model { ... @ManyToMany public List<Tag> tags; } @Entity public class Tag extends Model { ... @ManyToMany(mappedBy="tags") public List<Proposal> taggedProposals; } And I want to populate my DB with some test data using a yaml file (to display later using a simple view). This is part of my yaml file: ... - &prop2 !!models.Proposal id: 2 title: Prop2 title proposer: *user2 - &prop3 !!models

Ebean looks for wrong sequence name in Play Framework 2

爱⌒轻易说出口 提交于 2019-12-23 07:20:19
问题 I have an id: @Column(name = "device") @GeneratedValue(strategy = GenerationType.AUTO, generator = "device_gen") @SequenceGenerator(name = "device_gen", sequenceName = "device_id") @Id public Integer id; SequenceGenerator defines the sequenceName as device_id but trying to save an entity I get the error: relation "public.device_seq" does not exist . Why is it looking for device_seq instead of device_id ? I'm using PostgreSQL 回答1: @GeneratedValue(strategy=GenerationType.SEQUENCE, generator=

Is it possible to cast a SqlQuery results from Ebean to a Model (Bean)?

陌路散爱 提交于 2019-12-23 06:14:50
问题 Using Ebean (via Play Framework 2.1.1), I have to build a home made SQL query, but I'd like it to return directly a List<MyModel> , instead of a List<SqlRow> that I would have to query the database for each id from the result to have a List<MyModel> . Is it possible to cast directly a SqlQuery/SqlRow to a Model ? Actually, I do that : SqlQuery query = Ebean.createSqlQuery("SELECT id FROM MyModel WHERE ..."); List<SqlRow> rows = query.findList(); // not directly possible. List<MyModel> results

Use of BeanPersistAdapter in a Plugin

ぐ巨炮叔叔 提交于 2019-12-23 05:47:11
问题 In order to perform pre/post insert/update/delete actions ( isRegisterFor(Class<?> clazz) , postInsert(BeanPersistRequest<?> request) , ... ) with Ebean in Play, I implemented a class IndexAdapter extends BeanPersistAdapter . Works - app -- models --- Car --- Person --- House --- IndexAdapter -- controllers --- ... Everything went well until I decided to transform it (it's more than one class actually) into a Play plugin. Doesn't work - app -- plugin --- IndexAdapter -- models --- Car ---