Sure, we are using Hibernate 3.5.2 and search 3.2.0, although i saw this issue happening with search 3.1.0, however the exception in 3.1.0 was being swallowed so we didn't see anything until we started using 3.2.0
Here are the classes, i omitted some code in the classes i didn't think was relevant for brevity.
Code:
@Entity
@Indexed
@Table(name = "scorecardnodes")
@Proxy(proxyClass = com.spider.cms.hdao.IScorecardNode.class)
public class ScorecardNodeHDao extends BaseNodeHDao<IScorecardNode> implements IScorecardNode {
private IScorecardNode rootNode;
private Set<IScorecardNodeNote> notes;
...
@OneToMany(targetEntity = ScorecardNodeNoteHDao.class, mappedBy = "scorecardNode")
@IndexedEmbedded(targetElement = ScorecardNodeNoteHDao.class)
public Set<IScorecardNodeNote> getNotes() {
return notes;
}
public void setNotes(Set<IScorecardNodeNote> notes) {
this.notes = notes;
}
@ManyToOne(targetEntity = ScorecardNodeHDao.class, fetch = FetchType.LAZY)
@JoinColumn(name = "scorecardrootnodeid")
public IScorecardNode getRootNode() {
return rootNode;
}
public void setRootNode(IScorecardNode root) {
this.rootNode = root;
}
...
}
Code:
@Entity
@Table(name = "notes")
@Proxy(proxyClass = com.spider.cms.hdao.IScorecardNodeNote.class)
public class ScorecardNodeNoteHDao extends BaseDomainObjectWithIdHDao implements IScorecardNodeNote {
private IScorecardNode scorecardNode;
private IScorecardNodeNote rootNote;
private List<IScorecardNodeNote> replies = new ArrayList<IScorecardNodeNote>();
...
@ManyToOne(targetEntity = com.spider.cms.hdao.impl.ScorecardNodeHDao.class, fetch = FetchType.LAZY)
@JoinColumn(name = "scorecardnodeid")
@ContainedIn
public IScorecardNode getScorecardNode() {
// includes this so the scorecard node ID is definitely populated
if (scorecardNode == null && getRootNote() != null) {
return getRootNote().getScorecardNode();
}
return scorecardNode;
}
public void setScorecardNode(IScorecardNode scorecardNode) {
this.scorecardNode = scorecardNode;
}
@ManyToOne(targetEntity = com.spider.cms.hdao.impl.ScorecardNodeNoteHDao.class, fetch = FetchType.LAZY)
@JoinColumn(name = "rootnoteid")
public IScorecardNodeNote getRootNote() {
return rootNote;
}
public void setRootNote(IScorecardNodeNote root) {
this.rootNote = root;
}
@OneToMany(targetEntity = com.spider.cms.hdao.impl.ScorecardNodeNoteHDao.class, mappedBy = "rootNote", fetch = FetchType.LAZY)
@OrderBy(clause = "creationdate ASC")
@Cascade(CascadeType.DELETE)
public List<IScorecardNodeNote> getReplies() {
return replies;
}
public void setReplies(List<IScorecardNodeNote> replies) {
this.replies = replies;
}
...
}
We've encountered the error while trying to delete an object from the database using the code below
Code:
public void deleteScorecardNote(Integer noteId, String database) {
IScorecardNodeNote note = getScorecardNodeNote(noteId, false, database);
getHibernateTemplate(database).delete(note);
}
I'm not sure if this helps but while tracing through the execution, the ClassCastException is happening when the id method is being invoked on a proxied instance of IScorecardNode. Thanks for your assistance.