Ebean使用心得

一.自定义sql(我的使用的版本是11.22.5)

ebean.properties(xml所在文件夹)

ebean.mappingLocations=classpath:/ebean-xml-mappings

文件

文件内容官网:

<?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>
  </entity>

</ebean>

使用:

2.问题二 跨数据库

@Table(name = "tbl_oss_log",catalog="log")

3.in sql使用

Query<Product> subQuery =   
    Ebean.createQuery(Product.class)  
        .select("sku")  
        .where().idEq(4).query();  

List<MinCustomer> list = Ebean.find(MinCustomer.class)  
    .where().in("name", subQuery)  
    .findList(); 

猜你喜欢

转载自blog.csdn.net/zhaofengdeng/article/details/82971476