FK « Insert « JPA Q&A

1. Hibernate - handle add (insert) when fk self-reference in another class

I have Hibernate configs as follows. CPUModel:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "">
  <class name="org.example.CPUModel" table="cpu_model">
    <id name="cpuModelId" type="java.lang.Integer" unsaved-value="null">

2. MySQL Auto increment insert where autoincrement is a FK

Hi The subject is confusing but let me explain I have a MySQL DB I have a table called BOOK whose primary key(bookID) is a auto increment field My Book object has an attribute id which I set to 0 as mySQL knows that when doing an insert, the auto increment field will be set to zero. MySQL implicitly sets the ...

3. Does Hibernate detect wrong inserts in a FK?

Hi, I'm new in hibernate and have a simple question. When I don't create any keys in a db itself, just in the mapping-files of hibernate I create ids(PK) and many-to-one relations to simulate foreign keys. Will hibernate detect in the mapping if I would make wrong inserts to a FK-property? Thanks in advance and sorry for my bad english, Karl ...

4. Inserting two Objects with FK ; one-to-many instead -to-one

Regular Joined: Thu Apr 05, 2007 7:05 am Posts: 53 Location: Troisdorf, Germany Hello, i"ve a problem with a type of query I have to write. I have two tables "Item" and "Molecule". There is a one-to-one relationship between them. I wrote by now a query, which inserts the "Item"-object and the databse generates a unique primary key. Now I want ...

5. Inserts not maintaining FK references in mappin

... ... ...