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

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top