`
q_wong
  • 浏览: 105271 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

JPA調用存儲過程

JPA 
阅读更多

 PROCEDURE:

CREATE OR REPLACE PROCEDURE HTCHR.copy_BonusDept_From_HRM (
orgid in number,bonusorgid in number,hrmtype in number) is
BEGIN
delete from HTCHR.BONUSDEPARTMENT b where B.BONUSORGANIZATION_ID = bonusorgid;
insert into HTCHR.BONUSDEPARTMENT b (
B.ID,
B.CODE,B.FULLNAME,B.SHORTNAME,B.ENGLISHNAME,B.REPEALED,B.DEPTLEVEL,B.PLDEPT,B.ATTRIBUTE,
--B.MAINMANAGER_ID,
B.BONUSORGANIZATION_ID,
B.ADMINPARENT_ID
) 
select
concat(bonusorgid,'*'||D.id),
D.CODE,D.FULLNAME,D.SHORTNAME,D.ENGLISHNAME,D.REPEALED,D.DEPTLEVEL,D.PLDEPT,D.ATTRIBUTE,
replace(D.ORGANIZATION_ID,D.ORGANIZATION_ID,bonusorgid),
--D.MAINMANAGER_ID,
case hrmtype 
when 1
--DLine1
then
case
when D.DOTTEDONEPARENT_ID is not null
then
concat(bonusorgid,'*'||D.DOTTEDONEPARENT_ID)
else concat('',D.DOTTEDONEPARENT_ID)
end
when 2
--DLine2
then 
case
when D.DOTTEDTWOPARENT_ID is not null
then
concat(bonusorgid,'*'||D.DOTTEDTWOPARENT_ID)
else concat('',D.DOTTEDTWOPARENT_ID)
end
when 3
--SLine
then 
case
when D.SOLIDPARENT_ID is not null
then
concat(bonusorgid,'*'||D.SOLIDPARENT_ID)
else concat('',D.SOLIDPARENT_ID)
end
else
--行政
case
when D.ADMINPARENT_ID is not null
then
concat(bonusorgid,'*'||D.ADMINPARENT_ID)
else concat('',D.ADMINPARENT_ID)
end
end
from HTCHR.DEPARTMENT d where d.ORGANIZATION_ID = orgid;
end;
/

 

 JPA調用:

/**
	 * 復制HRM組織
	 * 
	 * @param orgId
	 * @param prefixStr
	 * @param hrmType
	 */
	public void copyFromHrm(Integer orgId,Integer bonusOrgId,Integer hrmType) {
		Query query = entityManager.createNativeQuery("{call copy_BonusDept_From_HRM(?,?,?)}");
		query.setParameter(1, orgId);
		query.setParameter(2, bonusOrgId);
		query.setParameter(3, hrmType);
		query.executeUpdate();
	}

 

 復制完刷新組織樹的時候需要refresh一下:

/**
	 * 刷新bonusOrganization
	 * 
	 * @param bonusOrganization
	 */
	public void refeshBonusOrganization(BonusOrganization bonusOrganization) {
		bonusOrganization.getBonusDepartments().clear();
		entityManager.refresh(bonusOrganization);
	}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics