Primary key « Column « JPA Q&A





1. How do I join tables on non-primary key columns in secondary tables?    stackoverflow.com

I have a situation where I need to join tables on an object in an ORM class hierarchy where the join column is NOT the primary key of the base class. ...

2. Table with no precise Primary Key Columns    forum.hibernate.org

I have an audit log table for maintaing history information related to the application with the foll. columns in Oracle. LOOKUP_TYPE VARCHAR2(40) NOT NULL, MODIFIED_BY VARCHAR2(30) NOT NULL, MODIFIED_DATE DATE NOT NULL, OLD_NAME VARCHAR2(100), NEW_NAME VARCHAR2(100), OLD_VALUE VARCHAR2(100), NEW_VALUE VARCHAR2(100) There is no precise primary key here. Functionally LOOKUP, MODIFIED_BY, MODIFIED_DATE and 2 of the foll. columns (OLD_NAME, NEW_NAME, OLD_VALUE, NEW_VALUE) ...

3. Updating primary key column(s) using Hibernate    forum.hibernate.org

anthony wrote: it's not possible, do it in a DAO method implemented using jdbc but be carefull with first and second level caches I am using a Stateless Session Bean in my application. And, retrieving the POJO in one EJB method and passing it on directly to the web-tier. The web-tier updates the POJO and sends it back to another EJB ...

4. How to do automatic generation of a non primary key column ?    forum.hibernate.org

I have a table lets say with following fields: id (which is primary key and of identity type) id2 (which is a normal column with lets say int data-type) In the mapping xml for this table, I am using "identity" algorithm for automatic generation of "id" column. Now the primary key "id" will be generated automatically whenever a new row is ...

5. Primary Key with more than one column    forum.hibernate.org

Hibernate version: 3.0 I fear I have overlooked the solution in the documentation or maybe I haven't understood the concept of Hibernate. I have a table-structure with a lot of tables having primary keys with more than one column. eg: Table person: firstName lastName dayOfBirth street zip city with primary key firstName, lastName and dayOfBirth and a table companyCar with a ...

6. many-to-one on non-primary-key column using annotation?    forum.hibernate.org

public class FirmUser implements Serializable{ private Login logn; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "username") public Login getLogin() { return login; } public void setLogin(Login login){ this.login = login; ...

7. Does the primary key have to be the first column in the tabl    forum.hibernate.org

Hi there, just trying to plug hibernate into some legacy tables and have come a bit unstuck with the primary key. In one of the tables the primary key is the second column in the table. Now when I create the objectname.hbm.xml I have to declare the ID before the property columns. This seems to imply that the primary key (or ...

8. How to refer unique columns, which are not primary keys    forum.hibernate.org

HI, Kindly suggest me a way using hibernate annotations, to refer unique column names from some other entity.e.g public class A implements Serializable { private String id; // this is the primary key for this entity private String columnA; private String columnB; // in this entity i have annotated combination of "columnA" and "columnB" as unique } Now i want to ...

9. Column Named ID is not Primary Key - SQL error    forum.hibernate.org

Hello everyone, i have a tiny problem that puzzles me all day long : Java Object : /** * @return the localKey * @hibernate.id generator-class="increment" column="localKey" */ public String getLocalKey(){ return localKey; } /** * @return the id * @hibernate.property column="id" */ public String getId() { return id; } --- as you can see, the primaryKey of the Database Table is ...





10. Primary key composed by several columns    forum.hibernate.org

11. Primary Key with a Hibernate generated ID and another column    forum.hibernate.org

I am a new Hibernate (v3) user. Having checked the internet (including this forum) and the Hibernate in Action book, I'm still unsure if this scenario can be handled via a Hibernate mapping file. Scenario: The Oracle database table we are mapping to has a primary key that includes two columns: one id that should be generated (e.g. Hibernate's sequence generator), ...

12. Primary Key with a Hibernate generated ID and another column    forum.hibernate.org

I am a new Hibernate (v3) user. Having checked the internet (including this forum) and the Hibernate in Action book, I'm still unsure if this scenario can be handled via a Hibernate mapping file. Scenario: The Oracle database table we are mapping to has a primary key that includes two columns: one id that should be generated (e.g. Hibernate's sequence generator), ...

13. Joining entities on non-primary key columns    forum.hibernate.org

I'm trying to join two tables, Project and Owner, that have a many-to-one relationship (Project has one Owner. An Owner has many Projects). The column that joins these two tables is unique, but not a primary key. In effect, I need to do the equivalent of the SQL query: SELECT ... FROM PROJECT P LEFT JOIN OWNER O ON P.ownername = ...

15. Define a Primary key with more than one column    forum.hibernate.org

Hi, I have a Groups table, which contains name and users id who has defined this group. However, the same user can define one and only one group with the same name. This way I need to define a contstraint that combination of name and user_id should be unique i.e multiple entries with same name and user id should not be ...





17. Update a column that is a member of a compound primary key    forum.hibernate.org

I have a 3 column primary key, ITEM_ID, END_DATE and MEMBER_ITEM_ID. This table contains membership information that is historical, is there a way to update the END_DATE when a member is removed. Currently updating the END_DATE and persisting the entity results in another record added to the table. Is there a way to update a column that is a member of ...