holyeye / devon2012 Goto Github PK
View Code? Open in Web Editor NEWdevon2012발표자료
devon2012발표자료
http://stackoverflow.com/questions/12135233/entity-not-recognizing-the-id-in-a-mappedsuperclass
와 관련된 내용입니다.
영한님의 BaseEntity 클래스를 상속받으면
상속받은 클래스에 다음과 같은 오류가 발생하면서 컴파일이 안되더군요.
the entity has no primary key attribute defined
상속받은 클래스에서 위와 같은 메시지가 출력됩니다.
그래서 BaseEntity를 다음과 같이 수정하였습니다. 위의 stackoverflow.com 의 내용을 참고로 하였습니다.
package kr.co.sunnyvale.guestbook.domain;
import java.io.Serializable;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import org.springframework.data.jpa.domain.AbstractPersistable;
@MappedSuperclass
@access(AccessType.PROPERTY)
public abstract class BaseEntity extends AbstractPersistable{
private static final long serialVersionUID = -8669707500586538457L;
@Version
@Access(AccessType.FIELD)
private long version;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public PK getId() {
return super.getId();
}
@Override
public void setId(PK id) {
super.setId(id);
}
}
혹시 더 좋은 방법이 있을까요? eclipse 의 jpa관련된 버그라는 말도 있는 듯 한데. eclipse는 최신버전인데 말입니다. ^^;;;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.