-->
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: Strange error
PostPosted: Sun Aug 31, 2003 10:04 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 11:33 pm
Posts: 38
I have two classes like the following. When I delete a catalog, I got this strange error:

hibernate exception caught! Unexpected exception: Failed to lazily initialize a collection: exception setting property value with CGLIB setter of hibernate.QuestionObjective.?


I don't understand what it means. Anyone can help ? Thanks a lot !

/**
* @hibernate.class
* table="catalog"
* mutable="true"
* proxy="hibernate.Catalog"
*/
public class Catalog {
private long id;
private String name;
private String iconUrl;
private Catalog catalog;
private Set subCatalogs;
private Set objectiveQuestions;
private Set subjectiveQuestions;

/**
* @hibernate.id
* column="id"
* unsaved-value="null"
* generator-class="native"
* @return
*/
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}

/**
* @hibernate.property
* column="name"
* not-null="false"
* unique="false"
* @return
*/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

/**
* @hibernate.property
* column="iconurl"
* not-null="false"
* unique="false"
* @return
*/
public String getIconUrl() {
return iconUrl;
}

public void setIconUrl(String iconUrl) {
this.iconUrl = iconUrl;
}

/**
* @hibernate.many-to-one
* column="pid"
* cascade="none"
* class="hibernate.Catalog"
* outer-join="false"
* unique="false"
* @return
*/
public Catalog getCatalog() {
return catalog;
}

public void setCatalog(Catalog catalog) {
this.catalog = catalog;
}

/**
* @hibernate.collection-one-to-many
* class="hibernate.Catalog"
* @hibernate.collection-key
* column="pid"
* @hibernate.set
* inverse="false"
* table="Catalog"
* lazy="true"
* cascade="delete"
* @return
*/
public Set getSubCatalogs() {
return subCatalogs;
}

public void setSubCatalogs(Set subCatalogs) {
this.subCatalogs = subCatalogs;
}

/**
* @hibernate.collection-one-to-many
* class="hibernate.QuestionObjective"
* @hibernate.collection-key
* column="cid"
* @hibernate.set
* inverse="false"
* table="objectiveQuestion"
* lazy="true"
* cascade="delete"
* @return
*/
public Set getObjectiveQuestions() {
return objectiveQuestions;
}

public void setObjectiveQuestions(Set objectiveQuestions) {
this.objectiveQuestions = objectiveQuestions;
}

/**
* @hibernate.collection-one-to-many
* class="hibernate.QuestionSubjective"
* @hibernate.collection-key
* column="cid"
* @hibernate.set
* inverse="false"
* table="subjectiveQuestion"
* lazy="true"
* cascade="delete"
* @return
*/
public Set getSubjectiveQuestions() {
return subjectiveQuestions;
}

public void setSubjectiveQuestions(Set subjectiveQuestions) {
this.subjectiveQuestions = subjectiveQuestions;
}
}

---------

/**
* @hibernate.class
* table="objectiveQuestion"
* mutable="true"
* proxy="hibernate.QuestionObjective"
*/
public class QuestionObjective {
private long id;
private String content;
private String filename;
private String instruction;
private String correctAnswer;
private Catalog catalog;
private QuestionType type;
private HardLevel level;
private int hits;
private Set tests;

public QuestionObjective() {
}

/**
* @hibernate.id
* column="id"
* unsaved-value="null"
* generator-class="native"
* @return
*/
public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

/**
* @hibernate.property
* column="content"
* not-null="false"
* unique="false"
* @return
*/
public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

/**
* @hibernate.property
* column="filename"
* not-null="false"
* unique="false"
* @return
*/
public String getFilename() {
return filename;
}

public void setFilename(String filename) {
this.filename = filename;
}

/**
* @hibernate.property
* column="instruction"
* not-null="false"
* unique="false"
* @return
*/
public String getInstruction() {
return instruction;
}

public void setInstruction(String instruction) {
this.instruction = instruction;
}

/**
* @hibernate.property
* column="correctanswer"
* not-null="false"
* unique="false"
* @return
*/
public String getCorrectAnswer() {
return correctAnswer;
}

public void setCorrectAnswer(String correctAnswer) {
this.correctAnswer = correctAnswer;
}

/**
* @hibernate.many-to-one
* column="cid"
* cascade="none"
* class="hibernate.Catalog"
* outer-join="false"
* unique="false"
* @return
*/
public Catalog getCatalog() {
return catalog;
}

public void setCatalog(Catalog catalog) {
this.catalog = catalog;
}

/**
* @hibernate.many-to-one
* column="typeid"
* cascade="none"
* class="hibernate.QuestionType"
* outer-join="false"
* unique="false"
* @return
*/
public QuestionType getType() {
return type;
}

public void setType(QuestionType type) {
this.type = type;
}

/**
* @hibernate.many-to-one
* column="lid"
* cascade="none"
* class="hibernate.HardLevel"
* outer-join="false"
* unique="false"
* @return
*/
public HardLevel getLevel() {
return level;
}

public void setLevel(HardLevel level) {
this.level = level;
}

/**
* @hibernate.property
* column="hits"
* not-null="false"
* unique="false"
* @return
*/
public int getHits() {
return hits;
}

public void setHits(int hits) {
this.hits = hits;
}

/**
* @hibernate.collection-many-to-many
* column="tid"
* class="hibernate.Test"
* @hibernate.set
* inverse="true"
* table="testObjectiveQuestionRelation"
* lazy="true"
* cascade="none"
* @hibernate.collection-key
* column="qid"
* @hibernate.collection-index
* column="qid"
* @return
*/
public Set getTests() {
return tests;
}

public void setTests(Set tests) {
this.tests = tests;
}
}

----

/**
* @hibernate.class
* table="subjectiveQuestion"
* mutable="true"
* proxy="hibernate.QuestionSubjective"
*/
public class QuestionSubjective {
private long id;
private String content;
private String filename;
private String keypoints;
private Catalog catalog;
private HardLevel level;
private QuestionType type;
private int hits;
private Set tests;

public QuestionSubjective() {
}

/**
* @hibernate.id
* column="id"
* unsaved-value="null"
* generator-class="native"
* @return
*/
public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

/**
* @hibernate.property
* column="content"
* not-null="false"
* unique="false"
* @return
*/
public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

/**
* @hibernate.property
* column="filename"
* not-null="false"
* unique="false"
* @return
*/
public String getFilename() {
return filename;
}

public void setFilename(String filename) {
this.filename = filename;
}

/**
* @hibernate.property
* column="keypoints"
* not-null="false"
* unique="false"
* @return
*/
public String getKeypoints() {
return keypoints;
}

public void setKeypoints(String keypoints) {
this.keypoints = keypoints;
}

/**
* @hibernate.many-to-one
* column="cid"
* cascade="none"
* class="hibernate.Catalog"
* outer-join="false"
* unique="false"
* @return
*/
public Catalog getCatalog() {
return catalog;
}

public void setCatalog(Catalog catalog) {
this.catalog = catalog;
}

/**
* @hibernate.many-to-one
* column="lid"
* cascade="none"
* class="hibernate.HardLevel"
* outer-join="false"
* unique="false"
* @return
*/
public HardLevel getLevel() {
return level;
}

public void setLevel(HardLevel level) {
this.level = level;
}

/**
* @hibernate.many-to-one
* column="typeid"
* cascade="none"
* class="hibernate.QuestionType"
* outer-join="false"
* unique="false"
* @return
*/
public QuestionType getType() {
return type;
}

public void setType(QuestionType type) {
this.type = type;
}

/**
* @hibernate.property
* column="hits"
* not-null="false"
* unique="false"
* @return
*/
public int getHits() {
return hits;
}

public void setHits(int hits) {
this.hits = hits;
}

/**
* @hibernate.collection-many-to-many
* column="tid"
* class="hibernate.Test"
* @hibernate.set
* inverse="false"
* table="testSubjectiveQuestionRelation"
* lazy="true"
* cascade="none"
* @hibernate.collection-key
* column="qid"
* @hibernate.collection-index
* column="qid"
* @return
*/
public Set getTests() {
return tests;
}

public void setTests(Set tests) {
this.tests = tests;
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 31, 2003 11:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Disable the reflection optimizer and you will get more detailed information.


Top
 Profile  
 
 Post subject: How to disable it ?
PostPosted: Sun Aug 31, 2003 11:32 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 11:33 pm
Posts: 38
Could u give some detailed information on how to disable it ?

thanks !


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 31, 2003 11:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
hibernate.cglib.use_reflection_optimizer

This is in the documentation! It is no easier for me to look up the property name than for you.


Top
 Profile  
 
 Post subject: I found the bug :)
PostPosted: Sun Aug 31, 2003 11:47 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 11:33 pm
Posts: 38
Thank you for your patience, gavin :)


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.