-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Why my program always insert NULL value to primary key?
PostPosted: Tue Dec 06, 2011 7:33 am 
Newbie

Joined: Tue Dec 06, 2011 7:21 am
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.