How can I list all classes loaded in a specific class loader

Try this. It’s a hackerish solution but it will do. The field classes in any classloader (under Sun’s impl since 1.0) holds hard reference to the classes defined by the loader so they won’t be GC’d. You can take a benefit from via reflection. Field f = ClassLoader.class.getDeclaredField(“classes”); f.setAccessible(true); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Vector<Class> classes … Read more

How to mix inheritance strategies with JPA annotations and Hibernate?

According to the Hibernate Reference Documentation it should be possible to mix different inheritance mapping strategies when using Hibernate’s XML-Metadata (…) Actually, it’s not really supported, they are “cheating” using a secondary table to switch from the single table strategy in the example of the documentation. Quoting Java Persistence with Hibernate: You can map whole … Read more

JPA: How to have one-to-many relation of the same Entity type

Yes, this is possible. This is a special case of the standard bidirectional @ManyToOne/@OneToMany relationship. It is special because the entity on each end of the relationship is the same. The general case is detailed in Section 2.10.2 of the JPA 2.0 spec. Here’s a worked example. First, the entity class A: @Entity public class … Read more

Make multiple dependent / cascading selection components in JSF

Put the bean in the view scope and get rid of any business logic in getter methods. The bean must be placed in the view scope so that all previous selections and new available items are remembered for subsequent postbacks, otherwise things will fail when JSF needs to validate the selected item against the list … Read more