-->
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: Mapping components using shared columns
PostPosted: Sat Aug 16, 2008 6:12 am 
Newbie

Joined: Tue Mar 11, 2008 7:52 am
Posts: 5
Hi all!

What I'm trying to do is some kind of "view" of a objects, mapped as a component. Let's say I have the following class:


Code:

@Entity
public class A {

    private Integer x;
    private Integer y;
    private Integer z;

    @Embedded
    private ComponentA a;
   
    @Embedded
    private ComponentB b;

    // etc...
}

@Embeddable
public class ComponentA {
    Integer x;
    Integer y;
    // etc...
}

@Embeddable
public class ComponentB {
    Integer y;
    Integer z;
    // etc...
}



What I want to do is that each component use several columns from class A, but at the same time, class A has them also mapped separately. Not only that but the components can share some columns also.

¿Is it possible in any way? Mapped as showed doesn't work as the shared columns names must be overriden.

I know that the way should be createn table views in the database but I wondered if there was any other way using mappings.

Thank you all.


Top
 Profile  
 
 Post subject: Re: Mapping components using shared columns
PostPosted: Tue Aug 19, 2008 1:21 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
satanicoPlan wrote:
What I want to do is that each component use several columns from class A, but at the same time, class A has them also mapped separately. Not only that but the components can share some columns also.

I don't understand what you mean. What do you try to achieve? What is your usecase?

satanicoPlan wrote:
¿Is it possible in any way? Mapped as showed doesn't work as the shared columns names must be overriden.

That's correct. In order to have multiple components of the same type you have to overrise column names.

--Hardy


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.