mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-23 15:12:58 +00:00
#765 - ENH: Add ebean.xml with support for named RawSql, also adds EbeanServer.createNamedQuery()
This commit is contained in:
1 parent
2c3c23725a
commit
c7c6410cd9
30 files changed
+1116
-132
No files matched your search
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<ebean xmlns="http://ebean-orm.github.io/xml/ns/ebean">
|
||||
|
||||
<entity class="com.avaje.tests.model.basic.OrderAggregate">
|
||||
<raw-sql name="default">
|
||||
<column-mapping column="order_id" property="order.id"/>
|
||||
<column-mapping column="total_items" property="totalItems"/>
|
||||
<column-mapping column="total_amount" property="totalAmount"/>
|
||||
<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 totalItems, sum(order_qty*unit_price) as totalAmount, 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="com.avaje.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>
|
||||
|
||||
</ebean>
|
||||
Reference in new issue
Block a user