Hi,
Currently our persistence layer for an application uses a JDBC framework and we'd like to move to hibernate. The db includes the following (simplified) table definitions where 'foos' have a many-to-one relationship with 'transformers'.
Code:
tbl_foos
-------
id : int
name : varchar
transformer_id : int
tbl_transformers
-------
id : int
class_name : varchar
A view has also been defined joining the tables;
Code:
vw_foos
------
id : int
name : varchar
class_name : varchar
The domain objects include a com.myco.Foo class;
Code:
package com.myco;
public class Foo {
private int id;
private String name;
private String className;
// accessors/mutators omitted
}
Is it possible to map Foo onto the vw_foos view for reading and have hibernate update the underlying tbl_foos when updating? The RDBMS doesn't allow the view to be updated directly.
Or must I define a class of type Transformer and a field of this type in class Foo? (which will mean a potentially large refactoring in the real app)
Many thanks!