-->
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.  [ 5 posts ] 
Author Message
 Post subject: reuse of mappings across tables
PostPosted: Tue Mar 23, 2004 4:56 pm 
Newbie

Joined: Tue Mar 23, 2004 4:38 pm
Posts: 3
Hi-

I've been using hibernate for about 6 months for pretty standard CRUD type database interactions and like it a lot. The app I'm working on now is driven by data in a huge (4TB) data warehouse. Information in the warehouse is surfaced through materialized views and the column names in those views are identical for a majority of the views. There are currently 6 materalized views and as the warehouse team gets more investigation requests, more views will be created.

To map this stuff up via hibernate, I've had to create a class per view and essentially cut and paste the properties in beween the mapping definitions for each view. I'm only in the proof-of-concept phase for using hibernate as part of my solution but I'm thinking that it's not going to work out due to all the redundancy between mappings. As the app grows things aren't going to be maintainable.

The issue of having multiple classes is no problem since the classes have all their members defined in a common parent class. The real issue is the duplication of property definitions across mapping nodes.

Is there a way to extend mappings and override certain attributes? Or can components be defined independent of a particular class mapping and then imported?

My current worst case solution is to write some kind of code generator that takes a mapping file of my own design and generates the hibernate mappings from it. The mapping file still contains all the redundancy but the maintenance point would have no redundancies.

Any suggestions are appreciated.


Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 7:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Its very easy; just use XML external entities :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2004 11:44 am 
Newbie

Joined: Tue Apr 13, 2004 11:34 am
Posts: 4
I think I have a similar question. We are evaluating Hibernate as a possible replacement of EJB CMP. One of the advantages that we have found with Entity Beans is that in our data model, we have several tables that contain nearly identical columns. We are able to have a single Entity Bean class gernerically represent those tables, and we simply deploy multiple EJBs with that bean class for each appropriate table. Ie, the same class represents different tables. Is there a way with Hibernate to create similar mappings? Such that we have a single class:

public class MyEntity {
private Long m_id;
public Long getId() { return m_id; }
public void setId(Long n) { m_id = n; }

private String m_name;
public String getName() { return m_name; }
public void setName(String n) { m_name = n; }
}


that maps to BOTH of these tables:

CREATE TABLE TABLE_A (
ID NUMBER NOT NULL,
NAME VARCHAR2(128) NOT NULL
)

CREATE TABLE TABLE_B (
ID NUMBER NOT NULL,
NAME VARCHAR2(128) NOT NULL
)

Is this possible in Hibernate, without having to create different subclasses for each table?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2004 11:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
In Hibernate 2.1, it is possible if you use multiple SessionFactories.

In Hibernate3 CVS, its is possible.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 15, 2004 10:18 am 
Newbie

Joined: Thu Apr 15, 2004 10:17 am
Posts: 14
Location: Manhattan
jimkski: Did you solve the problem you had? I am running into exactly the same mapping issue.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.