提交 de45e23c 编写于 作者: Lqyang5080's avatar Lqyang5080

hibernate模板

上级 e8a13f8f
...@@ -40,10 +40,63 @@ public class ${item.codeName}{ ...@@ -40,10 +40,63 @@ public class ${item.codeName}{
</#if> </#if>
</#list> </#list>
<#comment>输出当前关系从实体</#comment>
<#if item.getMinorPSDERs?? && item.getMinorPSDERs()??>
<#list item.getMinorPSDERs() as MinorPSDER>
<#assign MajorEntity = MinorPSDER.getMajorPSDataEntity()>
<#assign wjz = MinorPSDER.getPSPickupDEField()>
<#if MajorPSDER.getDERType()=='DER11'>
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name="${wjz.getName()?lower_case}",foreignKey = @ForeignKey(name = "${MinorPSDER.getName()}"))
private ${MajorEntity.getCodeName()} ${wjz.getName()?lower_case};
</#if>
<#if MajorPSDER.getDERType()=='DER1N'>
@ManyToOne
@JoinColumn(name="${wjz.getName()?lower_case}",foreignKey = @ForeignKey(name = "${MinorPSDER.getName()}"))
private ${MajorEntity.getCodeName()} ${wjz.getName()?lower_case};
</#if>
</#list>
</#if>
<#comment>输出当前关系主实体</#comment> <#comment>输出当前关系主实体</#comment>
<#if item.getMajorPSDERs?? && item.getMajorPSDERs()??> <#if item.getMajorPSDERs?? && item.getMajorPSDERs()??>
<#list item.getMajorPSDERs() as MajorPSDER> <#list item.getMajorPSDERs() as MajorPSDER>
//${MajorPSDER.getDERType()} <#assign MinorEntity = MajorPSDER.getMinorPSDataEntity()>
<#assign Entity_cap_first = MajorPSDER.getPSPickupDEField().getName()?lower_case>
<#if MajorPSDER.getDERType()=='DER11'>
@OneToOne(
mappedBy = "${Entity_cap_first}",
cascade = CascadeType.ALL,
orphanRemoval = true,
fetch = FetchType.LAZY
)
private ${MinorEntity.getCodeName()} ${MinorEntity.getCodeName()?lower_case}s;
public void add${MinorEntity.getCodeName()}(${MinorEntity.getCodeName()} ${MinorEntity.getCodeName()?lower_case}) {
${MinorEntity.getCodeName()?lower_case}.set${Entity_cap_first?cap_first}( this );
this.${MinorEntity.getCodeName()?lower_case}s = ${MinorEntity.getCodeName()?lower_case};
}
public void remove${MinorEntity.getCodeName()}() {
if ( ${MinorEntity.getCodeName()?lower_case}s != null ) {
${MinorEntity.getCodeName()?lower_case}s.set${Entity_cap_first?cap_first}( null );
this.${MinorEntity.getCodeName()?lower_case}s = null;
}
}
</#if>
<#if MajorPSDER.getDERType()=='DER1N'>
@OneToMany(mappedBy = "${Entity_cap_first}", cascade = CascadeType.ALL, orphanRemoval = true)
private List <${MinorEntity.getCodeName()}> ${MinorEntity.getCodeName()?lower_case}s = new ArrayList<>();
public void add${MinorEntity.getCodeName()}(${MinorEntity.getCodeName()} ${MinorEntity.getCodeName()?lower_case}) {
${MinorEntity.getCodeName()?lower_case}s.add( ${MinorEntity.getCodeName()?lower_case} );
${MinorEntity.getCodeName()?lower_case}.set${Entity_cap_first?cap_first}( this );
}
public void remove${MinorEntity.getCodeName()}(${MinorEntity.getCodeName()} ${MinorEntity.getCodeName()?lower_case}) {
${MinorEntity.getCodeName()?lower_case}s.remove( ${MinorEntity.getCodeName()?lower_case} );
${MinorEntity.getCodeName()?lower_case}.set${Entity_cap_first?cap_first}( null );
}
</#if>
</#list> </#list>
</#if> </#if>
<#assign str = ""/> <#assign str = ""/>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册