key « Entity « JPA Q&A





1. Hibernate - retrieving all entities referenced by foreign keys for a specific entity    stackoverflow.com

I´ve got a question similar to this one: How to find all foreign keys? I´d like to make Hibernate tell me whether an entity is referenced somewhere in the database by foreign ...

2. three-entity table with foreign keys to 2 two-entity tables.    forum.hibernate.org

I have 3 main tables: USER, GROUP, ROLE USER and GROUP many-to-many relationship is implemented via GROUP_USER table and GroupUser class. GROUP and ROLE many-to-many relationship is implemented via GROUP_ROLE table and GroupRole class. Now, for a given group, a user plays a particular role. So I then have another table called GROUP_USER_ROLE which has two complex foreign keys, one maps ...

3. many-to-one entity with foreign key saving problem    forum.hibernate.org

Hi, I have 2 classes: public class A implements Serializable(){ private Integer id; private Integer foreignId; A(){} public void setId(Integer id){this.id=id;} public Integer getId(){return this.id;} public void setForeignId(Integer id){this.foreignId=id;} public Integer getForeignId(){return this.foreignId;} } public class B implements Serializable(){ private Integer id; private Integer something; B(){} public void setId(Integer id){this.id=id;} public Integer getId(){return this.id;} public void setSomething(Integer s){this.something=s;} public Integer getSomething(){return ...

4. General practice - foreign keys and entities versus keys    forum.hibernate.org

This is more of a general practices question than a technical question. I have a fairly normalized database, and one of my tables has about 8 foreign keys (most of them nullable). Would it be better to store these foreign keys in the entity as java.lang.Long, store them as target entities, or both? If both, how do I keep the two ...

5. Persist an entity with foreign key    forum.hibernate.org

Hi, I am a newbie I am creating a POJO from a flat file which has a foreign-key relation with an existing table. I want to persist this entity into the database. Example: NewEntity @Id int id; String name; @JoinColumn(name="foreign_id", nullable=false) AnotherObject object; The flat file has a value for 'foreign_id' and if I want to populate the field, then I ...