-->
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: Using TABLE_PER_CLASS to create reusable components
PostPosted: Thu Jul 19, 2007 7:41 am 
Beginner
Beginner

Joined: Fri Apr 20, 2007 10:48 am
Posts: 49
Location: France
Hibernate version:3.2

Mapping documents:not appliable

Code between sessionFactory.openSession() and session.close():not applicable

Full stack trace of any exception that occurs: none

Name and version of the database you are using: not applicable

The generated SQL (show_sql=true):not applicable

Debug level Hibernate log excerpt:none

Hi hibernate team,

It's been almost 3 years that I develop using hibernate, you have a really great product and ideas on how to resolve problems.

Today I'm creating a new product for my own starting business. So I have less time constraints and orders on how I should do things. So naturally as a self respecting developer, I wanted to develop reusable components.

You might say, why a so long introduction? : for 3 years I didn't ask any question on the forum ;-)

So let's begin:
The idea is to create a class that gives to any subclass the behaviour of archiving it self (different versions with timestamps, notes and the archiving performer). Let's call this base class Archivable, and its different timestamped entries: ArchiveEntry

Here's an attempt of text UML
___________________
| Archivable |
|__________________|
^ 1
|
|
| 1
v__________________
| ArchiveEntry |
| ------------------------ |
|-created : Date |
|-invalidated : Date |
|-performer : Person |
|__________________|

The idea is to flag ArchiveEntry with @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) so we can have a different index of entries for every Archivable subclass.

Let's give an example: a Student (subclass of Archivable) that has a property 'grade' will have a StudentArchiveEntry every time its grade has evolved, so we can see all his cursus and who gave him every diploma.

The problem when I create a strucutre like this is that the database schema is created successfully, but when queries are made, there's a disaccordance in indexes.

here are my classes anotations:
@Entity
@IdClass(ArchiveId.class)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class ArchiveEntry
implements Serializable {
...}

@MappedSuperclass
@IdClass(ArchiveId.class)
public abstract class Archivable<T extends ArchiveEntry>
implements Serializable {
...}

@Entity
public class BasicPerson extends ArchiveEntry {
...}

Can you please help me find annotation is wrong? maybe it isn't the way I should resolve it at all...

Regards,
Zied


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.