Reputation:
I want to define a new Java class at runtime using some input information, for instance, from Files.readAllBytes(Paths.get(path));
and then map objects of this class to relational database via some ORM
or persistence API (MyBatis
, Hibernate
). Is it even possible to do this and if yes how to achieve this (what libraries, tools etc.)? My own idea is to use Jython metaclasses, but I think there are simpler solutions.
Upvotes: 1
Views: 404
Reputation: 64747
You can do it using The Compiler API
here is an example - http://www.accordess.com/wpblog/an-overview-of-java-compilation-api-jsr-199/
Upvotes: 2