Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Questions about Hibernate DataSources and Wildfly transaction provider

    SmartClient Version: v9.1p_2015-01-02/PowerEdition Development Only (built 2015-01-02)

    Hi,
    We have some questions about hibernate datasources:

    1. We have datasource B with relation many-to-one to datasource A.
    Is it true that, if we have 5 records from table A, hibernate will make 50 different sql calls to fetch related records from B table? If yes - is it possible to replace that 50 calls with one combined call without rewriting datasource?

    2. The second problem is that sometimes, based on search criteria we need to directly specify name of partitioned table (which is slightly different that base table, eg. messages and messages_2015_02). What is preferred way to achieve this?

    3. Is there a possibility to reuse existing persistence unit configuration(defined in persistence.xml file)? If yes, could you provide us with example configuration? And how should configuration look like so that datasource will use transaction provider from application server (wildfly)?

    Best regards
    Jacek

    #2
    First, for some background, take a look at JPA/Hibernate relations overview.

    1. Generally, the best thing is not to load the subrecords with the main record at all (see overview above for how to avoid this happening automatically), then load them on-demand by doing ordinary fetches against the 'B' DataSource.

    However, if you have a good reason to load the 'B' records up front, and your provider's implementation is poor enough that you can do better with a few normal Hibernate calls, you can write a DMI that returns the nested records without rewriting any other functionality of the HibernateDataSource.

    2. Can you clarify this - are you saying you have a single table structure with multiple identical tables that have the same structure, and you want to use a single DataSource to access it?

    3. Nothing normally needs to be changed here. There is a sample project included with the SDK where you can look at the persistence.xml file being used.

    Comment

    Working...
    X