나는 ArtistEntityBean
연장 하는 콩 이 있습니다 GenericEntityBean
:
public class ArtistEntityBean extends GenericEntityBean<Artist> {
public ArtistEntityBean() {
item = new Artist();
}
}
-
public abstract class GenericEntityBean<T extends IntEntity> implements Serializable {
protected T item;
public void init(Integer id){
item.setId(id);
}
}
-
public class Artist extends ArtistBaseEntity implements Comparable<Artist> {
...
}
-
public abstract class ArtistBaseEntity implements IntEntity {
...
}
-
public interface IntEntity {
Integer getId();
void setId(Integer id);
}
-
GenericEntityBean
클래스에 가능한 한 많은 코드를 넣으려고 노력하고 있습니다. 그래서 .NET Framework를 설정할 수 있도록 인터페이스를 사용하려고 생각 id
했습니다 item
.
NoSuchFieldError
생성자에서를 얻고 그 ArtistEntityBean
이유를 모르기 때문에 이것은 어렵지 않습니다 .
경우 item
이다 public
, protected
또는 당신이 사용이 기본
super.item = new Artist();
의 생성자에서 ArtistEntityBean
.
private
추상 클래스에서 setter 메서드를 제공해야하는 경우 .
편집 :item
추상 클래스에서 지정하지 않은 경우 다음을 수행하십시오.
public abstract class GenericEntityBean<T extends IntEntity> implements Serializable {
protected T item;
public void init(Integer id){
item.setId(id);
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다