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, '