I am sick of this error
I am developing a website using netbeans, hibernate and m$ sql server 2005
I have my clases and everything was going well but now i get the error bellow but not always sometimes it works sometimes it does not, I just don't get it
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/hibernate/proxy/EntityNotFoundDelegate
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:119)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at HibernateControllers.CategoryController.<init>(CategoryController.java:38)
The error is in categoryController, file a tuomatically generated by netbeans from my persistence.Category class
the error is here:
/** Creates a new instance of CategoryController */
public CategoryController() {
emf = Persistence.createEntityManagerFactory("VirtualShopMarketPU");
}
i just dont know what it is. cna someone give a me a hand my category class is the following :
@Entity
@Table(name = "dbo.tCategory")
@NamedQueries( {@NamedQuery(name = "Category.getCategoryById",
query = "SELECT c FROM Category c WHERE c.id = :id"),
@NamedQuery(name = "Category.getSubCategories",
query = "SELECT c FROM Category c WHERE c.parentCategoryId = :parentCategoryId")})
public class Category implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "id", nullable = false)
private Integer id;
@Column(name = "categoryName", nullable = false)
private String categoryName;
@ManyToOne
@JoinColumn(name = "parentCategoryId", nullable = false)
private Category parentCategoryId;
/** Creates a new instance of Category */
public Category() {
}
public Category(String categoryName) {
this.categoryName = categoryName;
}
public Category(String categoryName, Category parentCategoryId ) {
this.parentCategoryId = parentCategoryId;
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getCategoryName() {
return this.categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public void setAdminFirstName(String categoryName) {
this.categoryName = categoryName;
}
public Category getParentCategory() {
return this.parentCategoryId;
}
public void setParentCategory(Category parentCategoryId) {
this.parentCategoryId = parentCategoryId;
}
/**
* Determines whether another object is equal to this Category. The result is
* <code>true</code> if and only if the argument is not null and is a Category object that
* has the same id field values as this object.
* @param object the reference object with which to compare
* @return <code>true</code> if this object is the same as the argument;
* <code>false</code> otherwise.
*/
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Category)) {
return false;
}
Category other = (Category)object;
if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
return true;
}
/**
* Returns a string representation of the object. This implementation constructs
* that representation based on the id fields.
* @return a string representation of the object.
*/
@Override
public String toString() {
return this.categoryName;
}
public boolean hasNextSubCategory(){
if (index == null)
index = 0;
if (subCategories == null)
initSubCategories();
if (index.intValue() < subCategories.size())
return true;
index = 0;
return false;
}
public Category getSubCategory() {
if (subCategories == null)
initSubCategories();
if (index == null)
index = 0;
index++;
return (Category)subCategories.get(index - 1);
}
private void initSubCategories(){
CategoryController categoryController = new CategoryController();
subCategories = categoryController.getSubCategories(this);
}
@Transient
private Vector subCategories;
@Transient
private Integer index;
}
and I am calling it from here:
private DefaultMutableTreeNode getCategoryTree()
{
CategoryController categoryController = new CategoryController();
Category category = categoryController.findCategory(0);
this.trueCategory = category;
DefaultMutableTreeNode defaultMutableTreeNode = new DefaultMutableTreeNode(category);
reclusivejTreeFunction(category, defaultMutableTreeNode);
return defaultMutableTreeNode;
}
Thanks in advance !!
|