Chitika

Showing posts with label error. Show all posts
Showing posts with label error. Show all posts

Tuesday, December 30, 2014

Failed to read candidate component class

I was having following error,

Failed to read candidate component class: file [/a/b/c/z$1.class]; nested exception is java.lang.SecurityException: Prohibited package name: java.lang: Prohibited package name: java.lang applicationContext-jpa.xml /im4/src/main/resources/META-INF/spring line 5 Spring Beans Problem

When clicked on it, it opens applicationContext-jpa.xml, with line <repositories base-package="a.b.c" />

Looking into the code of z.java, it is found out that it is util class having package a.b.c, which spring scans for beans.

Changing the package to a.b.z resolves the issue.

Thursday, November 20, 2014

hibernate reverse engineering database - composite key, no many-to-many relationship

I was trying to generate hibernate code through hibernate tools but I was getting issue with association table being created as entity and another id entity was created, and many-to-many relationship was not recognized.

Most of the places, it is written that for many-to-many relationship, association table must have just two foreign keys and no other field. But they forget to mention that these two fields but be the composite primary key of that table.

By setting the foreign keys as composite primary key, hibernate successfully recognized it as many-to-many table along with neither entity of association table is created nor id entity was created. It works like a charm.