Auto generate « Key « JPA Q&A





1. Problem creating entries in a database using JPA and auto-generated primary keys    stackoverflow.com

I am a Java EE/JPA newbie, currently attending a beginners course on JEE programming. I am trying to create new entries in a database which has a sequence defined for generating an ID, ...

2. Don't require auto-generated Primary key    forum.hibernate.org

Hi, I don't require auto generated primary key to save in the database as my records are generated by the layer which is above hibernate and also generates the primary key for the record. How do I implement this feature through Hibernate in .hbm.xml file Is it important to have the generator class. Or should I implement something like composite key ...

3. About auto-generated keys and portability    forum.hibernate.org

Hi, this is just a "philosophical" question for the database gurus which inhabitate this forum. Let's say I have an application which must be portable to different databases. My tables all have an auto-generated id as a primary key, and unique indexes on "business" keys. I found this practice as a suggested one often in Hibernate documentation. Now, when I define ...

4. Getting auto-generated keys uses a problematic method    forum.hibernate.org

Hibernate version: 3.1.2 Full stack trace of any exception that occurs: java.sql.SQLException: [mercury][SQLServer JDBC Driver]Unsupported method: Connection.prepareStatement at com.mercury.jdbc.base.BaseExceptions.createException(Unknown Source) at com.mercury.jdbc.base.BaseExceptions.getException(Unknown Source) at com.mercury.jdbc.base.BaseConnection.prepareStatement(Unknown Source) Name and version of the database you are using: Sql Server 2000 The JDBC driver: Data Direct for Sql Server 3.5.27 When using Identity column in Sql Server, Hibernate tries to get the auto-generated keys. ...

5. How to assigned auto-generated PK to its FK - Please suggest    forum.hibernate.org

I have 2 table HOSPITAL and PATIENT with one-to-many relation. hospital_id is PK on HOSPITAL which is auto-increment and same hospital_id is FK on PATIENT. So, while inserting hospital object I want the auto-generated hospital_id from HOSPITAL should be inserted into PATIENT into one save. I have defined one-to-many relation in both mapping file. I am populating patient object as patient.setHospitalID(hospital.getHospitalID()); ...

6. Hibernate Auto Key Generation    forum.hibernate.org

I am not using Hibernate to generate my database in Oracle, because there were too many issues (can't specify constraint names, for example) that were a problem to the DBA. So, this is how I'm doing generated ids in Oracle: 1) Specify NUMBER(10) or NUMBER(21) as the datatype in Oracle. 2) Create a SEQUENCE in the database for that table. 3) ...

7. Auto generated Primary key and Foreign Key    forum.hibernate.org

Hi All, I have two table one is Event and second is EeventParam, primary key for event is auto generated, which is then used as foreign key in EventParam and there is one to many relationship between these two table.I want to persists objects in these two table in single session.save(Event e) call. but it is giving me ConstarintVailotion exception. After ...

8. Auto generated alternate key    forum.hibernate.org

9. Auto generated foreign key name    forum.hibernate.org

Hi I have looked around on the net and even put some output in the hibernate source to try and understand how the name for a foreign key is generated for example "fkb96df9aa146a5373". Our problem is that when we deploy with hbm2ddl auto set to update duplicated foreign key constraints with different ID's but are mapping the same columns. We wanted ...





10. Hibernate JPA not auto generating primary key    forum.hibernate.org

USE [PersistenceTest] GO /****** Object: Table [dbo].[LOGENTRY] Script Date: 07/02/2009 13:18:13 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[LOGENTRY]( [log_id] [int] NOT NULL, [Description] [nchar](50) NULL, [calories] [numeric](18, 0) NULL, CONSTRAINT [PK_LOGENTRY] PRIMARY KEY CLUSTERED ( [log_id] ASC )WITH (PAD_INDEX ...