Originally posted by Paul Sturrock:
Data in a database defined as an entity without a primary key is not relational data. So you will have problems using Hibernate (or any other ORM) with such data. The only fix is to correct your invalid entity relational model so everything has a primary key, ideally by adding surrogate keys.
If changing the ER model is not possible, the only workaround is to map your entities without primary keys so they have composite keys containing every attribute in the entity.
Adding to it,
If your table(Table I) has a one-to-one mapping with another table(Table II), probably you can map the use the primary key's value of Table I as a foreign(but mapped like a primary key) in table II.
Eg;
Consider Table I and Table II.
Table I is an unique entity and can stand on its own. Table II is also unique but it always has a one-to-one relationship with table I. Table II is never related to any other model, apart from a business rule which says if table II is accessed it is always accessed with Table I.
Here it is upto you to decide whether you need to have a surrogate key for Table II, which doesn't have any business/Front end significance and just for facilitating the use of hibernate.
On the other side,
you can define something like this on your Table II.hbm file,
But, each of these approaches has it own advantages and disadvantages. You need to decide which suits your business best.