Tutorial :Hibernate: Identifier



Question:

When using Hibernate:

Must I identify an id or composite id for each entity, What about if I want to use table without any primary key and without composite key ...

Thanx in advance


Solution:1

I you are working with a legacy schema then you need to have a look at composite-id.


Solution:2

A table without a key isn't a good relational model. I would not recommend it.

Hibernate's best practices say you should have an id. Composite ids are workable for legacy apps, but not always the best idea.

If you really must have a table without a key, I'd suggest that you shouldn't use Hibernate. It's an ORM tool, and it sounds like you're thinking about neither objects nor relational tables properly. Start with JDBC.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »