-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Is the following mapping possible..?
PostPosted: Tue Jan 06, 2004 6:33 am 
Newbie

Joined: Tue Jan 06, 2004 5:57 am
Posts: 3
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!


Top
 Profile  
 
 Post subject: Re: Is the following mapping possible..?
PostPosted: Tue Jan 06, 2004 12:13 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Map foo onto tbl_foo (not the view), add Transformer object and add a smart getter setter that will do the "view" job for you in Foo object

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.