-->
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.  [ 8 posts ] 
Author Message
 Post subject: Assignment of a NULL value to a NOT NULL column
PostPosted: Mon Apr 05, 2004 2:29 pm 
Newbie

Joined: Sun Apr 04, 2004 7:22 am
Posts: 5
Location: Bangalore
Hi

I'am having a table which does have one primary key and remaining columns are not null.

When I'm trying execute find with select query on that table its also trying to call update and
throwing SQL exception with "Assignment of a NULL value to a NOT NULL column".

Why is it trying to call update ? And whats the solution to this problem ?

Thanks in advance.

Regards
Malay.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 05, 2004 2:54 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
Malay,

Could you please post your mapping, java code, version of hibernate and database used? Can't help you without basic info.


Top
 Profile  
 
 Post subject: Assignment of a NULL value to a NOT NULL column
PostPosted: Mon Apr 05, 2004 7:45 pm 
Newbie

Joined: Sun Apr 04, 2004 7:22 am
Posts: 5
Location: Bangalore
Hi gpani

Please find here the details

<!-- Mapping for Table DTEST -->
<class name="com.test.hibernate.QueryTableDummy" table="DTEST">
<id name="dummyId" column="DTS_ID" type="int" unsaved-value="1">
<generator class="assigned" />
</id>

<property name="dummyName" type="string" column="DTS_NM" />
<property name="dummyEffDate" type="java.sql.Timestamp" column="DTS_EFF_DT" />
<property name="dummyTestId" type="string" column="DTS_TST_ID" />
<property name="dummyNameOpId" type="string" column="DTS_OPER_ID" />
<property name="dummyTs" type="java.sql.Timestamp" column="DTS_INS_TS" />
<property name="dummyEndDate" type="java.sql.Timestamp" column="DTS_END_DT" />
</class>

-- Script for table DTEST

create table DTEST
(
DTS_ID integer not null primary key,
DTS_NM varchar(60) not null,
DTS_EFF_DT date not null,
DTS_TST_ID varchar(8) not null,
DTS_OPER_ID varchar(8) not null,
DTS_INS_TS timestamp not null,
DTS_END_DT date not null
);

-- Mapping class

package com.test.hibernate;

import java.io.Serializable;
import java.sql.Timestamp;

/**
* @author guest
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class QueryTableDummy implements Serializable {

private int dummyId;
private String dummyName;
private Timestamp dummyEffDate;
private String dummyTestId;
private String dummyNameOpId;
private Timestamp dummyTs;
private Timestamp dummyEndDate;

public QueryTableDummy()
{
}

/**
* Returns the dummyEffDate.
* @return Timestamp
*/
public Timestamp getDummyEffDate() {
return dummyEffDate;
}

/**
* Returns the dummyEndDate.
* @return Timestamp
*/
public Timestamp getDummyEndDate() {
return dummyEndDate;
}

/**
* Returns the dummyId.
* @return int
*/
public int getDummyId() {
return dummyId;
}

/**
* Returns the dummyName.
* @return String
*/
public String getDummyName() {
return dummyName;
}

/**
* Returns the dummyNameOpId.
* @return String
*/
public String getDummyNameOpId() {
return dummyNameOpId;
}

/**
* Returns the dummyTestId.
* @return String
*/
public String getDummyTestId() {
return dummyTestId;
}

/**
* Returns the dummyTs.
* @return Timestamp
*/
public Timestamp getDummyTs() {
return dummyTs;
}

/**
* Sets the dummyEffDate.
* @param dummyEffDate The dummyEffDate to set
*/
public void setDummyEffDate(Timestamp dummyEffDate) {
this.dummyEffDate = dummyEffDate;
}

/**
* Sets the dummyEndDate.
* @param dummyEndDate The dummyEndDate to set
*/
public void setDummyEndDate(Timestamp dummyEndDate) {
this.dummyEndDate = dummyEndDate;
}

/**
* Sets the dummyId.
* @param dummyId The dummyId to set
*/
public void setDummyId(int dummyId) {
this.dummyId = dummyId;
}

/**
* Sets the dummyName.
* @param dummyName The dummyName to set
*/
public void setDummyName(String dummyName) {
this.dummyName = dummyName;
}

/**
* Sets the dummyNameOpId.
* @param dummyNameOpId The dummyNameOpId to set
*/
public void setDummyNameOpId(String dummyNameOpId) {
this.dummyNameOpId = dummyNameOpId;
}

/**
* Sets the dummyTestId.
* @param dummyTestId The dummyTestId to set
*/
public void setDummyTestId(String dummyTestId) {
this.dummyTestId = dummyTestId;
}

/**
* Sets the dummyTs.
* @param dummyTs The dummyTs to set
*/
public void setDummyTs(Timestamp dummyTs) {
this.dummyTs = dummyTs;
}

}
-------

And from my other class I'm calling the query something like the following

select dummy from dummy in class QueryTableDummy where dummyId = 10


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 7:54 am 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
Code:
When I'm trying execute find with select query on that table its also trying to call update and
throwing SQL exception with "Assignment of a NULL value to a NOT NULL column".


Malay,

The mapping and Bean look fine. Could you provide a sample of the code where you are doing a search? That is probably where you need to check if something is being updated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 10:17 am 
Newbie

Joined: Sun Apr 04, 2004 7:22 am
Posts: 5
Location: Bangalore
Hi

Basically I'm using Hibernate from Spring Framework.

Here is following the code :


package com.test.hibernate;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate.support.HibernateDaoSupport;

/**
* @author guest
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/

public class QueryTableDummyHibernateTest
extends HibernateDaoSupport{

public List getDummyData()
throws DataAccessException {

List lst =
getHibernateTemplate().find(
"select dummy from dummy in class QueryTableDummy where dummyId = 10 ");


System.out.println("Test data from Db -> "+lst);

return lst;
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 12:23 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
Do you use the ThreadLocal way of getting hibernate sessions in your getHibernateTemplate() method?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 8:11 am 
Newbie

Joined: Fri Mar 26, 2004 5:01 am
Posts: 2
gpani wrote:
Do you use the ThreadLocal way of getting hibernate sessions in your getHibernateTemplate() method?


Could you please explain the same in detail what do you mean by ThreadLocal way?. Why hibernate is calling update while selecting?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2004 8:21 am 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
Thirumoorthy wrote:
gpani wrote:
Do you use the ThreadLocal way of getting hibernate sessions in your getHibernateTemplate() method?


Could you please explain the same in detail what do you mean by ThreadLocal way?. Why hibernate is calling update while selecting?


1. I find it very difficult to believe that Hibernate would be doing an update when all you are doing in your code is a select. If this were really an issue, no one would be using Hibernate.

2. If you look through the Hibernate documentation regarding Session usage you will see code where you use sessions in conjunction with a ThreadLocal.


Please do some more research.


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

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.