-->
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.  [ 8 posts ] 
Author Message
 Post subject: Dynamic entities as Maps: howto
PostPosted: Mon May 30, 2005 10:56 am 
Newbie

Joined: Mon May 30, 2005 10:26 am
Posts: 13
Hello to you all,

that's my first post here, although some years ago I used the SF forums.

I have some questions regarding the java.util.Map representation of entities in Hibernate 3.
    - as it is presented in section 5.4 of the manual it looks like all Hibernate functionalities are perfectly available, only the representation is changed; is this conclusion correct?

    - if dynamic mapping is required because the DB entities may change at runtime, how can this be achieved? Well, yes, I know that Configuration.add() can add new entities to the curent mappings, but I need to overwrite some entity's mapping... The simple idea of reloading all mappings for all entities in a new Configuration object (just for one entity) is simply unacceptable, both in terms of computation time and temporary memory consumption. Are there any restrictions in the current codebase regarding mapping changes?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 30, 2005 11:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
one thing that won't work is recursive circular relationships since that is impossible to have with HashMaps. (you will get stackoverflowerror when hashcode is called)

you cant change mappings at runtime in the sessionfactory - for that you need to manipulate the configuration and rebuild a sessionfactory if that is unacceptable (i can't get why) then its too bad since I don't know other solutions. ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 30, 2005 11:28 am 
Newbie

Joined: Mon May 30, 2005 10:26 am
Posts: 13
I didnt' say a word about SessionFactory. I really have the sense of humour, but can you please re-read what I have actually written? That is, if you bother to answer.

OT: I know answering to a mirriad of idiot questions every day tends to form the habit of reading diagonally only certain words in paragraphs...


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 30, 2005 2:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you can perform all the mutations on the Configuration object you are capable of. The api is mainly targeted for *addition* and not for doing modifications but it should definitly be possible to do so.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 26, 2005 4:06 pm 
Newbie

Joined: Mon May 30, 2005 10:26 am
Posts: 13
Thanks a lot.
So, circular references among tables are forbidden and so are bidirectional associations :(


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 2:40 pm 
Newbie

Joined: Mon May 30, 2005 10:26 am
Posts: 13
But what if in line 20 of DynamicMapInstantiator.java gets replaced by
Code:
Map map = new IdentityHashMap();
? Does it hurt Hibernate?

Also, I see two mistakes related to putting "type" as key for the entity name in the Map representation:
    - there's no way to tell it from a property named "type" (see SessionImpl.java, line 1472)
    - it isn't advertised in the manual

The key name used for holding the entity's name should be more peculiar, like "<type>", "@type@" or so.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 2:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
put the type thingy in the jira.

i dont know what the full implications of identityhashmap would be - did it work for you ?

what happens if you put two different maps in a children set that represent the same child ? it should only put one of them in...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 2:32 pm 
Newbie

Joined: Mon May 30, 2005 10:26 am
Posts: 13
I must admit I didn't try it. You're right about your assumption, but it's the only way to rule out the infinte loop in equals() and hashCode().
But anyway, the error reported by kaared is not an outofmemoryexc!

As for reporting that "slip" on JIRA - I'll try to...


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