2

我想定义一个只读视图实体类。这就是为什么我像下课一样写。但根据项目使用的 jars 不包含 Subselect 和 Synchronize 注释类。为了解决这个问题,我尝试用旧的罐子更换一些罐子。但是又发生了不兼容的异常。如果哪个兼容的 jar 列表包含 org.hibernate.annotations.Subselect.class,我会强烈学习

在 ADF 平台和 Weblogic 10.3 中开发使用这些休眠版本:

hibernate3.jar
hibernate-annotations-3.4.0.GA.jar
hibernate-commons-annotations-3.3.0.ga.jar
hibernate-entitymanager-3.4.0.GA.jar
hibernate-validator-4.1.0.Final.jar

在需要使用 Subselect 注释类之前,这种组合对我来说已经足够且有用了

请帮助我提前谢谢Brgds

import com.arsivist.structure.BaseEntityView;

import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Subselect;
import org.hibernate.annotations.Synchronize;


@Entity(name = "IntegrationDepartment")
@Immutable
@Subselect("SELECT * FROM DEPARTMENTVIEW")
@Synchronize("DEPARTMENTVIEW")
public class IntegrationDepartment extends BaseEntityView
{
private IntegrationDepartment dependentDepartment;
private String code;
private String name;
private int departmentLevel;
private boolean excludeDistribution;

private Collection<IntegrationDepartment> departmentList;

public IntegrationDepartment()
{
entityName = "IntegrationDepartment";
departmentList = new ArrayList<IntegrationDepartment>();
}

public IntegrationDepartment(int id, String code)
{
entityName = "IntegrationDepartment";
departmentList = new ArrayList<IntegrationDepartment>();

this.id = id;
this.code = code;
}

@Id
@Column(name = "ID")
public int getId()
{
return id;
}

public void setId(int id)
{
this.id = id;
}

public void setDependentDepartment(IntegrationDepartment dependentDepartment)
{
this.dependentDepartment = dependentDepartment;
}

@ManyToOne(targetEntity = com.roketsan.integrationmodel.entity.IntegrationDepartment.class)
@JoinColumn(name = "DEPENDENTDEPARTMENTID")
public IntegrationDepartment getDependentDepartment()
{
return dependentDepartment;
}

public void setCode(String code)
{
this.code = code;
}

@Column(name = "CODE")
public String getCode()
{
return code;
}

public void setName(String name)
{
this.name = name;
}

@Column(name = "NAME")
public String getName()
{
return name;
}

public void setDepartmentLevel(int departmentLevel)
{
this.departmentLevel = departmentLevel;
}

@Column(name = "DEPARTMENTLEVEL")
public int getDepartmentLevel()
{
return departmentLevel;
}

public void setDepartmentList(Collection<IntegrationDepartment> departmentList)
{
this.departmentList = departmentList;
}

@OneToMany(mappedBy = "dependentDepartment")
@JoinColumn(name = "DEPENDENTDEPARTMENTID")
public Collection<IntegrationDepartment> getDepartmentList()
{
return departmentList;
}

public void setExcludeDistribution(boolean excludeDistribution)
{
this.excludeDistribution = excludeDistribution;
}

@Column(name = "EXCLUDEDISTRIBUTION")
public boolean isExcludeDistribution()
{
return excludeDistribution;
}

@Override
@Transient
public int compareTo(Object object)
{
if (!(object instanceof BaseEntityView))
throw new ClassCastException();

IntegrationDepartment baseEntity = (IntegrationDepartment)object;
Integer comparableElementA = getDepartmentLevel();
Integer comparableElementB = baseEntity.getDepartmentLevel();

return comparableElementA.compareTo(comparableElementB);
}

public String toString()
{
return "" + getCode();
}
}
4

0 回答 0