views:

36

answers:

1

This is weird and probably not possible but I'll ask anyway. I'm making this app that reads in a meta file and creates some tables then populates them with data. I was wondering if I could somehow use JPA to populate those tables. Obviously, there's no way I could have an entity with annotations on it since the table didn't exist at compile time. But perhaps JPA or the entity manager has a way to load data into a table that without an entity class?

If possible, I'd expect a method like

entityManager.update("myTableName", hashMapOfColumnNamesAndColumnDataValues);
+2  A: 

You could maybe use a native SQL query. Have a look at the EntityManager#createNativeQuery methods.

Pascal Thivent
Yes, I probably could but that has all the downsides i'm trying to avoid: It's not db independent, I've gotta write the sql by hand, etc. etc.
tieTYT
@tieTYT I understand but I'm not aware of something close to what you mentioned and I don't know any easy way to construct classes dynamically and to register them. In other words, I don't have any better suggestion.
Pascal Thivent