FK « Key « JPA Q&A





1. How can we change method for generating PK and FK names in hibernate?    stackoverflow.com

Can i provide some algorithm for generate smth intead of FK030HF9840303 for example?

2. Hibernate : self reference FK in same table as well as different table    stackoverflow.com

I have 2 tables as below

historyQuestions
=====================
question_id bigint(2) PK
question_master_id bigint(2) fk references question_master(question_id)
parent_question_id bigint(2) fk references historyQuestions(question_id)
parent_answer_id bigint(2) fk references historyAnswers(answer_id)

historyAnswers
=====================
answer_id bigint(2) pk
question_id bigint(2) fk references historyQuestions(question_id)
answer_master_id bigint(2) fk references answer_master(answer_id)
Now I ...

3. Hibernate smart enough to avoid FK issues?    coderanch.com

Hi Guys : Is Hibernate smart enough that, to insert "objects" in such an order that the underlying database doesnt throw foreign key errors ? Im using the hibernate reverse engineering tool that does all the object creation / hibernate code generation for you, I assume that my hibernate code will be ideal. -j

4. Hibernate FK and listbox    zkoss.org

5. One-To-Many (FK Problem)    forum.hibernate.org

I have two tables Table A ID int (PK) ID2 int Table B ID int (PK) A_ID int A_ID2 int I have created two classes one for table A named ClassA and one for table B named ClassB. A has a list with elements of B. Both ids of A are needed to find the entries in B. classB.hbm.xml Code:

6. How to handle JPA's @One-to-one FK @NotFound ?    forum.hibernate.org

I have a table , with a FK that links to another table. But that table may be modified by PHP programs, So, my FK may be invalid. I hope it become null . I see a @NotFound annotation in Hibernate But I see no similar option in JPA How to solve this ? Thanks a lot. environment : hibernate-distribution-3.3.2.GA hibernate-annotations-3.4.0.GA ...

7. Get FK y PK from hibernate API    forum.hibernate.org

Hi, I am displaying hibernate entities and I would like to get Relations from JDBC or XBM.XML files. I am sure It could be done from de API but I do not find out. What I am looking for is equivalents for java.sql.DatabaseMetaData ResultSet getPrimaryKeys(String catalog, String schema, String table) ResultSet getImportedKeys(String catalog, String schema, String table) ResultSet getExportedKeys(String catalog, String ...

8. one-to-one not associating FK to primary PK    forum.hibernate.org

I have two tables - account table with account_id SERIAL (from sequence) PK - user_info with id SERIAL (from another sequence) PK AND with account_id NOT NULL FK referencing account.account_id I want these table to be related one-to-one through unique FK of user_info table. I'm using Hibernate 2.1 property-ref feature to get right property association like this: Account.hbm.xml --------------------

9. accessing table with only FK an without PK    forum.hibernate.org

I have table CUSTOMER with id CUS_ID, and table CUSTOMER_ADD with attribute CUS_ID which is FK on CUSTOMER and attribute varchar(255) MISC. Because CUSTOMER_ADD does not have PK it must be as collection in CUSTOMER. Here is mapping Customer.hbm.xml: ...





10. Confused about FK    forum.hibernate.org

Hibernate version: 2.1 Name and version of the database you are using:MySql 3.23.57 Hello, I am new to Hibernate and a little confused over how the relationships work. I have been reading the online docs and the ebook 'Hibernate in Action' - very good book. I have two objects Library and Book, Library one-to-many Book. Each has its own PK(generated using ...

11. Controlling names of FK and PK generation    forum.hibernate.org

I can control the foreign key names, but is there any way to control the PK names generated? Our DBAs "prefer" (read enforce) a system along the lines of PK_A for the primary key of table "A_RTAB". Im digging through the Hibernate source - but in order to save myself a fruitless task, is there anyway to define the PK name? ...

12. Self Reference w/ non-PK, non-FK using a single Table    forum.hibernate.org

From your description, it seems that you'd like to have each AtItem maintain the same set of objects: all AtItems with the same simil_key. Is this correct? That's kind of a strange way to set up a relation. For that I would provide a DAO method "getAllSimilarItems(key)" that returns a collection of AtItems with the matching simil_key using a normal query. ...

13. Setting fk directly in many-to-one.    forum.hibernate.org

I've looked at the forumns and Hibernate-in-action book but I seem to not be able to figure out how to do something that seems should be simple. I have a simple table that maps persons to groups.. person_to_group fk person_id references persons fk group_id references groups groups pk id name persons pk id name Now it seems to me that I ...

14. 2 fk's, one colum. How?    forum.hibernate.org

Hi, I'm having trouble with mapping a relationship. I have a table with 3 fk's. 2 of share the same column. The way I have this mapped is not working. The mapping: The error: ERROR: Repeated column in mapping for ...

15. FK from multiple tables    forum.hibernate.org

16. How to specify FK that is not PK of other table    forum.hibernate.org

I can't figure out how to do something. I have one table named "authority" that has Id, username, and privilege. I have another table named "user_account" that has Id, and username. I want to be able to just add Authority objects to the UserAccount object and have it persisted in these tables. How do I configure Authority.hbm.xml so that the "username" ...





18. ${FK_Table}By${col_name}???    forum.hibernate.org

Override foreignKeyToCollectionName in the ReverseEngineeringStrategy, e.g. Code: public String foreignKeyToCollectionName(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns, boolean uniqueReference) { String propertyName = super.foreignKeyToCollectionName(keyname, fromTable, fromColumns, referencedTable, referencedColumns, uniqueReference); ...

19. many to one on multiple FK's    forum.hibernate.org

Author Message Sven_Vl Post subject: many to one on multiple FK's Posted: Tue May 01, 2007 10:21 am Newbie Joined: Thu Mar 22, 2007 10:39 am Posts: 14 Hey, I'm having trouble creating the mapping of a many to one relationship. the problem: - every 'task' should have one 'taskState'-object - when a task gets updated, the 'taskState'-object changes ...

21. problem assigning a FK    forum.hibernate.org

I get this below error during FK assignment... Foreign key (FK7C93E25F6DCEB433:APP.UTILIZEDPARTICIPANTOPPORTUNITY [TARGETED_TIMESTAMP])) must have same number of columns as the referenced primary key (APP.TARGETEDPARTICIPANTOPPORTUNITY [OPPORTUNITY_ID,BENEFICIARY_ID,TARGETED_TIMESTAMP]) Below are the hbm files for APP.TARGETEDPARTICIPANTOPPORTUNITY and APP.UTILIZEDPARTICIPANTOPPORTUNITY ... Please suggest if my assignment is wrong ... APP.TARGETEDPARTICIPANTOPPORTUNITY

22. 2 recent posts on this subject - fk in 2nd table    forum.hibernate.org

Hi, There is my previous post and a post from frer on June 24 on this same subject, so it seems like its confusing to more than just myself. Table 1 (person): pk integer ... Table 2 (data): pk integer; fk integer; ... All the examples show a fk onetoone where the Table1 has the fk field, but my structure has ...