====== ORM ======
===== 개요 =====
[[egovframework:rte:psl:orm|ORM]] Service 를 적용해서 (egovframework-ormcivilappealsample)으로 별도 구현되어 있다.
===== 설명 =====
==== Configuration ====
=== resources\META-INF\persistence.xml ===
org.hibernate.ejb.HibernatePersistence
egovframework.rte.cvpl.service.CvplUser
=== resources\spring\context-jpa.xml ===
=== resources\spring\context-datasource.xml ===
=== resources\spring\context-transaction.xml ===
==== Source ====
=== egovframework\rte\cvpl\service\CvplUser.java ===
@Entity
@SqlResultSetMapping(name="setMap",
columns = { @ColumnResult(name = "totCnt") })
@Table(name="RTETNORMUSER")
@NamedQueries({
@NamedQuery(name = "selectCvplUserList",
query = "FROM CvplUser cvplUser"),
@NamedQuery(name = "selectCvplUserId",
query = "FROM CvplUser cvplUser
WHERE cvplUser.userId = :searchKeyword ORDER BY cvplUser.userId"),
@NamedQuery(name = "selectCvplUserName",
query = "FROM CvplUser cvplUser
WHERE cvplUser.userName like :searchKeyword ORDER BY cvplUser.userName")
})
public class CvplUser implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "USER_ID", length=20)
private String userId;
@Column(name = "USER_NAME", length=20)
private String userName;
.
.
.
=== egovframework\rte\cvpl\service\impl\CvplUserDAO.java ===
@Repository("cvplUserDAO")
public class CvplUserDAO {
@PersistenceContext
private EntityManager em;
.
.
.
String strQl = "selectCvplUserList";
String searchCondition = searchVO.getSearchCondition();
String searchKeyword = searchVO.getSearchKeyword();
if( "0".equals(searchCondition) ) {
strQl = "selectCvplUserId";
} else {
strQl = "selectCvplUserName";
searchKeyword = "%" + searchKeyword + "%";
}
Query qlQuery = em.createNamedQuery(strQl);
qlQuery.setParameter("searchKeyword", searchKeyword);
qlQuery.setFirstResult(searchVO.getFirstIndex());
qlQuery.setMaxResults(searchVO.getRecordCountPerPage());
return qlQuery.getResultList();
.
.
.