Hi, having some one2may or many2many relation, and having mapped it to hibernate as sets or any other way I need to get these relations in a sliced mode, I mean, in case there are a lot of related entities (millions) I want to get one range (30-60).
I would do that with startIndex and endIndex If I knew the query to do, but from hibernate API I do not know the joining fields. (It is a requirement, as I am working on a software library that gets a connection object and works on mapped classes with no previous knowledge of the classes, I cannot hardcode fields or classes or relations to build the "where", I get class information from ClassMapping object, obtained fromgetAllClassMetadata).
I do not know how would an hibernate expert do it. I am researching on two ways. 1) Some way to use limits in the mapped entity class get method 2) Trying to get the query hibernate uses on 1) so I can do a common query in which I can apply limits.
I also tried getTableMappings to get DB info, but as I can get FKs information they are DB level relations, not class level relations and did not help. Neither did I manage to map DB fields to attribute fields. This would probably help too. I also thought of reading xml config files to map DB fields to attributes and convert in these way DB relations to class relations and make the query, but this do not seems very smart.
Thanks beforehand, I am stucked with this problem for three days and I do not see the way.
Thanks again, txemi.
|