-->
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.  [ 6 posts ] 
Author Message
 Post subject: try to insert null into a non-nullable column
PostPosted: Sun Jan 18, 2004 1:53 pm 
Newbie

Joined: Sun Jan 18, 2004 1:43 pm
Posts: 1
Hi!

we have a problem concerning about synchronizing database state with session

business.run output:
[code]2004-01-18 18:17:20,282 : SessionFactoryImpl.<init> : Query language substitutions: {no='N', true=1, yes='Y', false=0}
Hibernate: insert into QUESTION (TEXT, TYPE, COMPARABLE, PARENT_ID, CLASS_NAME, ID) values (?, ?, ?, ?, 'QuestionDTO', ?)
2004-01-18 18:17:23,857 : JDBCExceptionReporter.logExceptions : SQL Error: -10, SQLState: 23000
2004-01-18 18:17:23,857 : JDBCExceptionReporter.logExceptions : Try to insert null into a non-nullable column: 23000 Try to insert null into a non-nullable column in statement [insert into QUESTION (TEXT, TYPE, COMPARABLE, PARENT_ID, CLASS_NAME, ID) values ('TestParentQuestion', 'Lernfrage', FALSE, NULL, 'QuestionDTO', 'nullz


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 2:56 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
QuestionDTO has probably not-null properties, remove these constraints

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 10:54 am 
Newbie

Joined: Mon Jan 19, 2004 7:35 am
Posts: 2
emmanuel wrote:
QuestionDTO has probably not-null properties, remove these constraints


Hi,

Here the Code QuestionDTO:

Code:
package org.openuss.group.business.entity;

import java.util.*;

import org.openuss.group.specification.business.*;


public class QuestionDTO implements java.io.Serializable, Question {
    // Primary Key
    private String id;

    // Object state
    private String text;
    private String type;
    private Question parentQuestion;
    private boolean comparable;

    public String getId() throws QuestionException {
        return id;
    }

    public void setId(String id) throws QuestionException {
        this.id = id;
    }

    public String getText() throws QuestionException {
        return text;
    }

    public void setText(String text) throws QuestionException {
        this.text = text;
    }

    public String getType() throws QuestionException {
        return type;
    }

    public void setType(String type) throws QuestionException {
        this.type = type;
    }

    public boolean getComparable() throws QuestionException {
        return comparable;
    }

    public void setComparable(boolean Comparable) throws QuestionException {
        this.comparable = comparable;
    }

    public Question getParentQuestion() throws QuestionException {
        return parentQuestion;
    }

    public void setParentQuestion(Question parentQuestion)
                           throws QuestionException {
        this.parentQuestion = parentQuestion;
    }
}




And here the new Mapping.hbm.xml

Code:
<hibernate-mapping>
<!-- mapping Question -->
    <!-- interface Question -->
    <class name="org.openuss.group.specification.business.Question"
           table="QUESTION"
           discriminator-value="null">
        <id name="id" column="ID">
            <generator class="uuid.string" />
        </id>
        <discriminator column="CLASS_NAME" />
        <property name="text" column="TEXT" not-null="true" />
        <property name="type" column="TYPE" not-null="true" />
        <property name="comparable" column="COMPARABLE" not-null="true" />
        <many-to-one name="parentQuestion" column="PARENT_ID" not-null="false"
                     class="org.openuss.group.business.entity.QuestionDTO" />
        <!-- class Question -->             
        <joined-subclass name="org.openuss.group.business.entity.QuestionDTO"
                         table="QUESTION_DTO">
            <key column="QUESTION_ID"/>
<!-- mapping NumberQuestion -->
            <!-- interface NumberQuestion -->
            <joined-subclass name="org.openuss.group.specification.business.NumberQuestion"
                             table="NUMBER_QUESTION">
                <key column="QUESTION_DTO_ID"/>
                <property name="maxValue" column="MAX_VAL" not-null="false"/>
                <property name="minValue" column="MIN_VAL" not-null="false"/>
                <!-- class NumberQuestion -->
                <joined-subclass name="org.openuss.group.business.entity.NumberQuestionDTO"
                                 table="NUMBER_QUESTION_DTO">
                    <key column="NUMBER_QUESTION_ID"/>
                </joined-subclass>
            </joined-subclass>
<!-- end mapping NumberQuestion -->
<!-- mapping ChoiceQuestion -->
            <!-- interface ChoiceQuestion -->       
            <joined-subclass name="org.openuss.group.specification.business.ChoiceQuestion"
                             table="CHOICE_QUESTION" >
                <key column="QUESTION_DTO_ID"/>
                <many-to-one name="choiceCharacteristics"
                             column="CHOICE_CHARACTERISTICS"
                             class="org.openuss.group.specification.business.ChoiceCharacteristics" />
                <property name="listHeight" column="LIST_HEIGHT" not-null="true" />
                <!-- (abstract) class ChoiceQuestion -->
                <joined-subclass name="org.openuss.group.business.entity.ChoiceQuestionDTO"
                             table="CHOICE_QUESTION_DTO" >
                    <key column="CHOICE_QUESTION_ID"/>
<!-- mapping SingleChoiceQuestion -->
                    <!-- interface SingleChoiceQuestion -->
                    <joined-subclass name="org.openuss.group.specification.business.SingleChoiceQuestion"
                                     table="SINGLE_CHOICE_QUESTION">
                        <key column="CHOICE_QUESTION_DTO_ID"/>
                        <!-- class SingleChoiceQuestion -->
                        <joined-subclass name="org.openuss.group.business.entity.SingleChoiceQuestionDTO"
                                         table="SINGLE_CHOICE_QUESTION_DTO">
                            <key column="SINGLE_CHOICE_QUESTION_ID"/>
                        </joined-subclass>
                    </joined-subclass>
<!-- end mapping SingleChoiceQuestion -->
<!-- mapping MultipleChoiceQuestion -->
                    <!-- interface MultipleChoiceQuestion -->       
                    <joined-subclass name="org.openuss.group.specification.business.MultipleChoiceQuestion"
                                     table="MULTIPLE_CHOICE_QUESTION" >
                        <!-- class MultipleChoiceQuestion -->
                        <key column="CHOICE_QUESTION_DTO_ID"/>
                        <joined-subclass name="org.openuss.group.business.entity.MultipleChoiceQuestionDTO"
                                         table="MULTIPLE_CHOICE_QUESTION_DTO">
                            <key column="MULTIPLE_CHOICE_QUESTION_ID"/>
                        </joined-subclass>
                    </joined-subclass>
<!-- end mapping MultipleChoiceQuestion -->
                </joined-subclass>
                <!-- end mapping class ChoiceQuestion -->
            </joined-subclass>
<!-- end mapping interface ChoiceQuestion -->
<!-- mapping TextQuestion -->
            <!-- interface TextQuestion -->   
            <joined-subclass name="org.openuss.group.specification.business.TextQuestion"
                             table="TEXT_QUESTION" >
                <key column="QUESTION_DTO_ID"/>
                <property name="inputFieldMaxLength" column="INPUT_FIELD_MAXLENGTH" not-null="true" />
                <property name="inputFieldWidth" column="INPUT_FIELD_WIDTH" not-null="true" />
                <property name="inputFieldHeight" column="INPUT_FIELD_HEIGHT" not-null="true" />
                <!-- class TextQuestion -->
                <joined-subclass name="org.openuss.group.business.entity.TextQuestionDTO"
                                 table="TEXT_QUESTION_DTO" >
                    <key column="TEXT_QUESTION_ID"/>
                </joined-subclass>
            </joined-subclass>
<!-- end mapping TextQuestion -->   
        </joined-subclass>
<!-- end mapping Question -->
    </class>
</hibernate-mapping>



new SQL Statement:

Code:
create table QUESTION (
   ID VARCHAR(255) not null,
   CLASS_NAME VARCHAR(255) not null,
   TEXT VARCHAR(255) not null,
   TYPE VARCHAR(255) not null,
   COMPARABLE BIT not null,
   PARENT_ID VARCHAR(255),
   primary key (ID)
);
create table QUESTION_DTO (
   QUESTION_ID VARCHAR(255) not null,
   primary key (QUESTION_ID)
);
[



same Exception:


[code]
2004-01-19 15:45:07,146 : SessionFactoryImpl.<init> : Query language substitutions: {no='N', true=1, yes='Y', false=0}
Hibernate: insert into QUESTION (TEXT, TYPE, COMPARABLE, PARENT_ID, ID) values (?, ?, ?, ?, ?)
Hibernate: insert into QUESTION_DTO (QUESTION_ID) values (?)
2004-01-19 15:45:09,440 : JDBCExceptionReporter.logExceptions : SQL Error: -10, SQLState: 23000
2004-01-19 15:45:09,440 : JDBCExceptionReporter.logExceptions : Try to insert null into a non-nullable column: 23000 Try to insert null into a non-nullable column in statement [insert into QUESTION (TEXT, TYPE, COMPARABLE, PARENT_ID, ID) values ('TestParentQuestion', 'Lernfrage', FALSE, NULL, '


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 11:02 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't believe you.
You replaced subclass by joined-subclass so the discriminator column must be in the insert query. You don't show me the truth.

BTW, you can set not-null properties in joined-subclass (this is another table)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 1:44 pm 
Newbie

Joined: Mon Jan 19, 2004 7:35 am
Posts: 2
[quote="emmanuel"]I don't believe you.
You replaced subclass by joined-subclass so the discriminator column must be in the insert query. You don't show me the truth.
[quote]

Why should I lie?
This is exactly the Qutput I get...

But I got the Error:
It was the discriminator column as you said:
Code:
<class name="org.openuss.group.specification.business.Question"
           table="QUESTION">
        <id name="id" column="ID">
            <generator class="uuid.string" />
        </id>


had a

Code:
        <discriminator column="CLASS_NAME" />


and the joined-subclass can't have a discriminator-value.
Deleting these rows resolved the Error

Thanks for the help.

Gert


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 4:04 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
twixxiwt wrote:
Why should I lie?
and the joined-subclass can't have a discriminator-value.


Sorry, I f***** up. I mismatch subclass and joined-subclass :(

_________________
Emmanuel


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