It is sometimes tedious to add class names manually to the persistence.xml file for hibernate configuration.
Is there a way to quickly generate the <class>com.something.Entity1</class>
part of the file?
Asked
Active
Viewed 1,127 times
1

lawal
- 952
- 10
- 19
1 Answers
1
Found a simple way, using the code from dzone. And just print them out and copy from the console. Here it is for anyone interested.
Class[] classex = getClasses(Entity1.class.getPackage().getName());
for (Class c : classex) {
if (c.getName().contains("$")) continue;
if (!c.isAnnotationPresent(javax.persistence.Entity.class)) continue;
System.out.println("<class>" + c.getName() + "</class>");
}

lawal
- 952
- 10
- 19