-->
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.  [ 5 posts ] 
Author Message
 Post subject: DB field NULL caused a NULL object in List using Criteria
PostPosted: Fri Sep 16, 2005 1:03 pm 
Newbie

Joined: Thu Sep 08, 2005 11:37 am
Posts: 8
This is my Class.hbm.xml:

generated with middlegen and hbm2java (unfortunately this table has not a PrimaryKey).

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
   
<hibernate-mapping>
<!--
    Created by the Middlegen Hibernate plugin 2.2

    http://boss.bekk.no/boss/middlegen/
    http://www.hibernate.org/
-->

<class
    name="Class"
    table="CLASS"
    lazy="false"
>

    <composite-id>
        <key-property
            name="Id"
            column="ID"
            type="java.lang.Integer"
            length="10"
        />
        <key-property
            name="description"
            column="DESCRIPTION"
            type="java.lang.String"
            length="10"
        />
    </composite-id>   


    <!-- Associations -->
    <!-- derived association(s) for compound key -->
    <!-- end of derived association(s) -->
 

</class>
</hibernate-mapping>


This is my DB:

Code:
ID         |        DESCRIPTION
________________________________
1          |        Test
2          |        NULL


when in my business-class, using Hibernate Criteria, I try to retrieve the DB ROW
the first one is correctly instantiated to a Class Object
the second one is NULL

why ?

how can I allow NULL value in DESCRIPTION column ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 16, 2005 1:18 pm 
Beginner
Beginner

Joined: Tue Aug 16, 2005 11:06 pm
Posts: 46
set not-null="true" for both properties when they are used for a composite key.

_________________
Jason Li
Don't forget to rate:)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 16, 2005 1:21 pm 
Newbie

Joined: Thu Sep 08, 2005 11:37 am
Posts: 8
there is a way in Middlegen to auto-generate this property ?

Thanks

Fabio


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 16, 2005 1:37 pm 
Beginner
Beginner

Joined: Tue Aug 16, 2005 11:06 pm
Posts: 46
I am pretty sure you can generate a property with not-null="true" when you database has not-null constraint for the corresponding column.

_________________
Jason Li
Don't forget to rate:)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 19, 2005 4:10 am 
Newbie

Joined: Thu Sep 08, 2005 11:37 am
Posts: 8
hi all,

this is my hbm.xml:

Code:
<composite-id>
        <key-property
           not-null="false" // I set false because in my db this field is nullable
            name="id"
            column="ID"
            type="java.lang.Integer"
            length="10"
        />

..
..
..
</composite-id>


the output Error:

[19/09/05 9.03.38:601 CEST] 736f736f XMLHelper E org.hibernate.util.XMLHelper Error parsing XML: XML InputStream(33) the attribute "not-null" must be declared for element type "key-property".
[19/09/05 9.03.38:601 CEST] 736f736f XMLHelper E org.hibernate.util.XMLHelper Error parsing XML: XML InputStream(41) the attribute "not-null" must be declared for element type "key-property".
[19/09/05 9.03.39:038 CEST] 736f736f WebGroup E SRVE0026E: [Errore servlet]-[]: java.lang.ExceptionInInitializerError
at java.lang.Throwable.<init>(Throwable.java)
at java.lang.ExceptionInInitializerError.<init>(ExceptionInInitializerError.java:73)
at java.lang.Class.initialize(Class.java)
at it.fiditalia.struts.business.HibEntityBusiness.selectWebuserslog(HibEntityBusiness.java)
at it.fiditalia.struts.actions.HelloAction.execute(HelloAction.java:40)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:443)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
Caused by: java.lang.RuntimeException: Configuration problem: Error reading resource: it/fiditalia/hib/entity/Webuserslog.hbm.xml
at java.lang.Throwable.<init>(Throwable.java:59)
at java.lang.Throwable.<init>(Throwable.java:73)
at it.fiditalia.hib.manager.HibernateUtil.<clinit>(HibernateUtil.java:20)
at java.lang.Class.initializeImpl(Native Method)
at java.lang.Class.initialize(Class.java)
at it.fiditalia.struts.business.HibEntityBusiness.selectWebuserslog(HibEntityBusiness.java)
at it.fiditalia.struts.actions.HelloAction.execute(HelloAction.java:40)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:443)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)


What's the problem ?

thanks in advance


fabio


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.