Hi, All
I am working on a ETL program, but my program always inset NULL value to primary key for one table, other tables work fine.
In the table "cache_usage", the primary key is "test_id", and there is a foreign key "cache_config_pk1".
In cacheUsage.hbm.xml
Code:
...
<id
name="testId"
type="java.lang.Integer"
column="test_id"
>
<meta attribute="field-description">
@hibernate.id
generator-class="native"
type="java.lang.Integer"
column="test_id"
</meta>
<generator class="native" />
</id>
...
And the java code:
Code:
... ...
tascu.setTestId( Integer.valueOf( testId ) );
session.save( tascu );
... ...
But it always throws out "Cannot insert the value NULL into column 'test_id'" error. the primary key is NOT NULL.
The INSERT query from STDOUT
Code:
insert
into
cache_usage
(total_inmemory_element_count, memory_hits, memory_misses, disk_hits, cache_size, total_element_count, end_time_relative, end_time_absolute, cache_config_pk1)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?)
Debugged with log4j, the values had been set for INSERT query. As you see, there isn't "test_id" in the query, but for other insert queries also no primary key in the query, those queries work fine.
Thanks in advanced for your comments.