Note that there are some explanatory texts on larger screens.

plurals
  1. PONHibernate: mapping single column from many-to-one to a primitive type
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COI think by not creating class Role, you have a discrepancy between your java object hierarchy and your database model. Your DB has Role(Id, Name) - no two Role records should have the same Name; when a Role Name is updated, all PersonRoles should reflect the change. All PersonRoles with the "USER" role should refer to the same Role object. Using a String in your Java code, you are providing client code a means to assign arbitrary values, not just existing table values. You could cause duplicate name entries in the table. You can work around Hibernate to do this anyway, but IMHO it isn't wise.
      singulars
    2. COTo _have a discrepancy between your java object hierarchy and your database model_ is the whole point of having an advanced mapping framework for me -- so I can have objects modeled by object rules, and db modeled by db rules. Right now I do want to allow clients to produce arbitrary values, and want these values to be added to the DB or reused if there is already same one here (solving the duplicates problem).
      singulars
    3. COSeems that you are actually after the enumerator-pattern, but then without a declared `enum` type. This really is easiest if you allow Role to be a class with an associated DAO for Update/Add etc and a unique constraint. I hinted at the practices of using `IDaoXXX` in an update of my answer. Note that "code bloat" is not always "bad bloat": to make programming this kind of business rules (re-use if exists, but updateable) far easier. This type of business rules should *never* go into the mapping (entity) layer (apart from the constraints) but should go in the access (dao) layer.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload