-->
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.  [ 1 post ] 
Author Message
 Post subject: Dynamically Configure Model Relationships
PostPosted: Thu Sep 27, 2007 1:07 am 
Beginner
Beginner

Joined: Thu Nov 20, 2003 1:30 pm
Posts: 27
I run into this problem a lot. I want to make components reusable, but because of relationships I can't. Let me explain...

The User module
I have User.class which contains
emailAddress, password, etc...

The Content module
Content.class holds images and text and other things.
It has a field user, that is ManyToOne in order to know who owns that content.

UserExtension module
I need to extend User.class to store a bunch of specific data for an application.

The problem I run into is

Content content = getContentFromSomewhere();
User user = content.getUser();
UserExtension extension = getUserExtention(user);

I'm looking for way to be able to get UserExtension directly from content. It would just make life a lot easier when writing queries and such.

Is there anything to 'tell' the Content.class that its relationship is with UserExtension and not User (User is just a MappedSuperclass). So I could do something like:

UserExtension extension = (User) content.getUser();

I always run into problems like this. I want to keep code simple and reusable for many projects. Currently I create a lot of 'boilerplate' code, like wrapper classes to hold a Content.class and a UserExtension.class. Then a bunch of methods to retrieve them all the various ways.


Thoughts anyone?

Thanks!


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

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.