In my business, I will to dynamically create model and repository for MySQL. I have successfully create the java file and complied it. then register the bean for repository and service using beanfactory. But I don't have an idea about how to map the Entity. I have searched some similar questions but do not have a clean solution. can anyone help and show me some code samples ?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
JPA works mostly with static schema. There are good reasons for this, see discussion on www.java.net/node/666078 .
I know only about 3 solutions:
1) refactor/ change your domain model to be static ( best way but there are some real world situations where you really need at least 1 or 2 dynamic tables)
2) use native queries and @SqlResultSetMapping for dynamic tables ( this is solution I am using in such special cases)
3) use Jpa provider non portable specific ways ( in fact not JPA) see for example http://www.infoq.com/articles/hibernate-custom-fields