Primary Key « Entity « JPA Q&A





1. JPA entity for a table without primary key    stackoverflow.com

I have a MySQL table without primary key, and I have to map it into a JPA entity. I cannot modify the table in any way. Because entities must have a primary ...

2. Hibernate - Saving Entities - Update Table - Not based on Primary Key    stackoverflow.com

Pseudo code to get to the point:

@Entity
Person {
   @Id
   Integer id;
   String SSN;
   String name;
}
Use case for repository, or service:
personRepository.save(new Person(ssn:"123456", name:"jeff")):
  • id is ...

3. Is createCriteria() same as Restrictions if its on the entity primary key?    stackoverflow.com

In the Hibernate Criteria API, there are methods to create Criteria over a criteria, rooted at the sub=-entity. These are good when you have to compare some non-key attribute of the ...

4. Separate entity for primary keys    stackoverflow.com

I have two tables as below.enter image description here "User Acc" is user's profile details and user's login details(username password) are in a seperate table called login.When I generated the ...

5. How can i write a JPA Entity without a primary Key    forum.hibernate.org

How can i write a JPA Entity without a primary Key ? My DB table is combined from two columns (user_id, company_id) both are foreign keys with manyToOne relation. Code: @Entity @Table(name="COMPANY_CONTACTS") public class CompanyContacts { @EmbeddedId private CompanyContactsPK companyContactsPK; } @Embeddable public class ...

6. Entity references by non-primary keys    forum.hibernate.org

I'm building a server that uses hibernate for it's data layer and I hava a client that creates entities through a remote interface. Let's say that the client wants to create a new entity A which have many-to-one references to the already persisted entities B, C and D. The entities B, C and D have primary keys generated by the server ...

7. ORM design question: Weak Entity Primary Key    forum.hibernate.org

Hi, For some time Ive been using surrogate keys for identifying all entities in my database. Although this sounds logical to me when applied to the main entities in my domain model, it does not seem to add much for weak entities, which will carry the key generated for their owning entities and will always be referenced through the main entity. ...

8. HOWTO: A base entity with a flexible primary key    forum.hibernate.org

I've seen a few base entity implementations before, and the one thing that always kept me from doing it was @Id @GeneratedValue(strategy=GenerationType.AUTO) protected Long id; What if i don't want to auto number rows with a bigint? Maybe i want to use a String or a composite primary key? This lack of flexibilty was a deal breaker for me. I found ...

9. Entity as part of the primary Key    forum.hibernate.org





10. 1 entity in 2 tables each with its own primary key    forum.hibernate.org

I have a class and its attributes: Class User -private int userId; -private String firstName; -private String lastName; -private String username; -private String password; I would like to store firstName and lastName on table A while username and password on table B. Is it possible for table A to have fields -userId ->primary key -firstName -lastName -bId ->foreign key and table ...

11. Updating and entity with primary key zero    forum.hibernate.org