开发者

Database Abstraction Language for Java

The problem: I need to abstract my database interaction on my application. The thing is JPA doesn't work for me because the tables/schemas are dynamic and I only know them at runtime. I thought of creating the classes dynamically, but I'm looking at performance problems with that approach since every insertion would result in an instantiation of the class using reflection. I thought about using XML to model, but seems al开发者_如何学JAVAso slow and a bit difficult to manage.

What am I looking for? I'm looking for some middle layer language (something like JPQL [Java Persistence Query Language]) that I don't need to map to objects. Some language that abstracts schema/catalog and table creation as well queries using select clause.

Thanks in advance.


I'm pretty sure hibernate has an object-less mode, where entities are described using Maps. and, you can setup a hibernate factory at runtime if you so desire. i believe the combination of these features could do what you need.

that said, i worked on a similar system at my last job. we wanted a functionality layer which was abstracted from the data layer. the data layer wasn't "dynamic" per-se, it was just not known at compile time. we ended up building a system which loaded a configuration file which defined the db schema and could generate sql against that schema. we wanted a pretty high level of control over the resulting sql, so we ended up building our own sql building library, which we open sourced as SqlBuilder. SqlBuilder works best for generating queries using an in-memory db schema (which we built from the config file).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜