I am running:
Eclipse 6.0.1GA on XP
SQL Server 2005
Hibernate3.jar
I have a simple table as:
CREATE TABLE [dbo].[DirectoryType](
[id] [int] NOT NULL,
[description] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [id] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
[description] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
I used MyEclipse to reverse engineer the Hibernate mappings.
<class name=”DirectoryType” table=”DirectoryType” schema=”dbo” catalog=”ISM_Dev”>
<id name=”id” type=”java.lang.Integer”>
<column name=”id” />
<generator class=”native”></generator>
</id>
<property name=”description” type=”java.lang.String”>
<column name=”description” length=”50″ not-null=”true” unique=”true” />
</property>
</class>
Here is my Java to persist:
DirectoryType dt = new DirectoryType();
dt.setId(null); // this actually makes no difference
dt.setDescription(“test directory type”);
session.saveOrUpdate(dt);
I am able to select values out of the table, but not insert. I did a show-sql and get this on the insert:
Hibernate: insert into ISM_Dev.dbo.DirectoryType (description) values (?)
To me that says that the HSQL isn’t being build correctly (because the actual text isn’t in the sql, nor is the id referenced, but I am new to Hibernate so I don’t know for sure.
I have searched and searched and all examples show the above code/configuration to be correct. I would greatly appreciate any help you can offer
thanks,