#2075 - Refactor external mapping (i.e. named queries from ebean.xml etc) - extract api and separate module

This commit is contained in:
rob bygrave committed 2020-10-12 14:54:25 +13:00
1 parent f57db28f1c
commit 49b1bd54c3
52 files changed
+817 -259

No files matched your search

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ebean xmlns="http://ebean-orm.github.io/xml/ns/ebean">
<entity class="org.tests.model.basic.Customer">
<named-query name="withContactsById2">
<query>
select (name, version)
fetch contacts (firstName, lastName, email)
where id = :id
</query>
</named-query>
</entity>
</ebean>
@@ -1,77 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ebean xmlns="http://ebean-orm.github.io/xml/ns/ebean">
<dto class="io.ebean.NamedDtoQueryTest$DCust">
<raw-sql name="findList">
<query>
select id, name from o_customer
</query>
</raw-sql>
<raw-sql name="findGtId">
<query>
select id, name from o_customer where id > :id
</query>
</raw-sql>
<raw-sql name="findGtIdDesc">
<query>
select id, name from o_customer where id > :id order by id desc
</query>
</raw-sql>
<raw-sql name="findByName">
<query>
select id, name from o_customer where name = :name
</query>
</raw-sql>
<raw-sql name="findByName_c3">
<query>
select c3.id, c3.name from o_customer c3 where c3.name = :name
</query>
</raw-sql>
<raw-sql name="findByName_c4">
<query>
select c4.id, c4.name from o_customer c4 where lower(c4.name) = :name
</query>
</raw-sql>
<raw-sql name="findListByName">
<query>
select c.id, c.name, count(o.id) as totalOrders
from o_customer c
join o_order o on o.kcustomer_id = c.id
where c.name like :name
group by c.id, c.name
</query>
</raw-sql>
</dto>
<dto class="io.ebean.NamedDtoQueryTest$DCust2">
<raw-sql name="findByName_relaxedMode">
<query>
select id, '42' as something_we_cannot_map, name from o_customer
</query>
</raw-sql>
<raw-sql name="findList">
<query>
select id, name from o_customer
</query>
</raw-sql>
</dto>
<dto class="io.ebean.NamedDtoQueryTest$DCust3">
<raw-sql name="findByName_relaxedMode">
<query>
select id, name, 42 as total, '42' as something_we_cannot_map from o_customer
</query>
</raw-sql>
<raw-sql name="findByNameLike">
<query>
select id, name, 42 as totalOrders from o_customer where name like ?
</query>
</raw-sql>
<raw-sql name="findByName">
<query>
select id, name from o_customer where name = :name
</query>
</raw-sql>
</dto>
</ebean>
@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ebean xmlns="http://ebean-orm.github.io/xml/ns/ebean">
<entity class="org.tests.model.basic.Order">
<raw-sql name="myRawTest2">
<alias-mapping alias="c" property="customer"/>
<alias-mapping alias="a" property="customer.billingAddress"/>
<query>
select o.id, o.status, o.ship_date, c.id, c.name, a.id, a.line_1, a.line_2, a.city
from o_order o
join o_customer c on o.kcustomer_id = c.id
join o_address a on c.billing_address_id = a.id
where o.status = :orderStatus
order by c.name, c.id
</query>
</raw-sql>
<raw-sql name="myRawTest3">
<column-mapping column="o.id" property="id"/>
<column-mapping column="o.status" property="status"/>
<query>
-- must be unparsed raw sql
select o.id, o.status
from o_order o
</query>
</raw-sql>
</entity>
</ebean>
-59
View File
@@ -1,59 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ebean xmlns="http://ebean-orm.github.io/xml/ns/ebean">
<entity class="org.tests.model.basic.OrderAggregate">
<raw-sql name="default">
<column-mapping column="order_id" property="order.id"/>
<query>
select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount
from o_order_detail
group by order_id
</query>
</raw-sql>
<raw-sql name="withMax">
<column-mapping column="order_id" property="order.id"/>
<query>
select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount, max(order_qty*unit_price) as maxAmount
from o_order_detail
group by order_id
</query>
</raw-sql>
<raw-sql name="withParam">
<column-mapping column="order_id" property="order.id"/>
<query>
select order_id, count(*) as totalItems, sum(order_qty*unit_price) as totalAmount, max(order_qty*unit_price) as maxAmount
from o_order_detail where id > :minId
group by order_id
</query>
</raw-sql>
</entity>
<entity class="org.tests.model.basic.Order">
<raw-sql name="myRawTest">
<alias-mapping alias="c" property="customer"/>
<alias-mapping alias="a" property="customer.billingAddress"/>
<query>
select o.id, o.status, o.ship_date, c.id, c.name, a.id, a.line_1, a.line_2, a.city
from o_order o
join o_customer c on o.kcustomer_id = c.id
join o_address a on c.billing_address_id = a.id
where o.status = :orderStatus
order by c.name, c.id
</query>
</raw-sql>
</entity>
<entity class="org.tests.model.basic.Customer">
<named-query name="withContactsById">
<query>
select (name, version)
fetch contacts (firstName, lastName, email)
where id = :id
</query>
</named-query>
</entity>
</ebean>
@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ebean xmlns="http://ebean-orm.github.io/xml/ns/ebean">
<entity class="org.tests.model.basic.OrderAggregate">
<raw-sql name="default">
<column-mapping column="order_id" property="order.id"/>
<query>
select order_id, count(*) as totalItems, sum(order_qty*unit_price) as totalAmount
from o_order_detail
group by order_id
</query>
</raw-sql>
<raw-sql name="default">
<column-mapping column="order_id" property="order.id"/>
<query>
select order_id, count(*) as totalItems, sum(order_qty*unit_price) as totalAmount
from o_order_detail
group by order_id
</query>
</raw-sql>
</entity>
</ebean>