Hibernate version: 3.0.5
Name and version of the database you are using: SQL Server 2000
We have used Hibernate 3 in a fairly complex project and it is an excellent tool. Though we had performance issues with large number of objects, we were able to achieve acceptable response time after following the guidance given in reference documentation. I would say that Hibernate is one of the best-documented open-source tool.
The project requires export of transactions between two offices. Each office has an independent database and application server instance. For example, I have to export sales invoice from one instance to the other instance. The sales invoice has many entities that are mapped with many-to-one relationship, such as branch, customer, item, etc.
We are using surrogate keys for PK for most of the entities, as the natural keys are composite for most of the entities. Since these generated keys could be different in destination database, we will be sending only natural keys as part of the sales invoice. However, in the destination instance, the information will not be inserted unless I fill these objects with its surrogate ids, for which I have to use criteria query that uses natural key as the criteria.
The problem is that for each entity that is part of sales invoice, I have to make separate call to the database. This is causing performance issues for the import.
Is there a way where we can achieve the equivalent of:
INSERT INTO salesInvoiceHdr (invoiceNumber, invoiceDate, ..., branchId, customerId)
SELECT ?, ?, ..., branch.id, customer.id
FROM branch, customer
WHERE (branch.comanyCode = ? and branch.branchCode = ?)
and (customer.companyCode = ? and customer.customerCode = ?)
Thanks for your help.
|