`

PBDP项目未解决问题总结

 
阅读更多

1. 持久层实体注解@Entity中增加name属性导致HQL查询异常

    @Entity(name="greenpages.jpa.model.Listing")
    @Table(name="LISTING")
    public class Listing implements Serializable{

    ......   

    }

 

    String queryString = "select l from Listing l where upper(l.lastName) like ?";
    List<Listing> list = this.getHibernateTemplate().find(queryString,new Object[]{"%" +

    term.toUpperCase() + "%"});

 

    说明:当@Entity注解指定name属性时,上述查询语句:queryString或写成:

    select l from greenpages.jpa.model.Listing l where upper(l.lastName) like ?,

    都将产生异常:

    org.hibernate.QueryException: in expected: l [select l from Listing l where upper(l.lastName)

    like ?],

    若不指定该属性,则查询语句:queryString也可写成:

    select l from greenpages.jpa.model.Listing l where upper(l.lastName) like ?,查询均成功。

2.

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics