How to add primary key column in existing table for hibernate WITHOUT actually adding column to it

StackOverflow https://stackoverflow.com/questions/21569448

문제

I am using Spring+HibernateDAO and want to access a table which does not have a primary key. Because Hibernate requires that entity tables have primary keys. ,I need to create some virtual primary key(perhaps), just to fool hibernate (it satisfies with @Id only) Or doing any efforts on database side without touching existing table is also fine. Please suggest any workaround which does NOT require ALTER EXISTING TABLE , any other table inheritance/structure changes are welcome.

PS. Already using JDBC template with manual mapping of columns to custom object.DB is Sybase ASE15 if it matters.

도움이 되었습니까?

해결책

There are some many answers to your question on stack-overflow itself, I am surprised, you didn't find one :P

How to work with tables without PRIMARY KEY in Hibernate?

Hibernate and no PK

Hibernate without Primary Key

This one on CodeRanch

Analyse and make your choice :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top