-->
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.  [ 7 posts ] 
Author Message
 Post subject: Mapping without classes
PostPosted: Thu Feb 09, 2006 9:36 am 
Newbie

Joined: Thu Feb 09, 2006 9:20 am
Posts: 3
Dear All,
I'm a newbie. I'm trying to use Hibernate as persistance layer on a new framework. What I need is to use hibernate without writing Java code for modeling "dummy and simple classes".
For example:
Code:
class  Country {
  private Long id;
  private String country;

  public set... > setters

  public get... > getters
}


for me is a dummy class. I don't want to write it but I can write the mapping file (.hbm.xml) file.

I tried to manage this trough the PersistentClass + Configuration classes without success... but is this possible? Or not at all?

Many thanks
Ivan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 1:11 pm 
Newbie

Joined: Mon Jul 11, 2005 8:34 am
Posts: 12
Hi el_coda!

I'm not sure I understand your question... are you asking if you could have the hbm.xml file without the class/object that represents the hbm.xml file? if so, as far as I know, you MUST have the class with attributes (the same attributes as in your hbm.xml) so that Hibernate can use it.
Hope that helps.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 1:32 pm 
Newbie

Joined: Thu Feb 09, 2006 9:20 am
Posts: 3
Hi, thanks.
You are right. In my project I want to manage dinamically the persistance layer for simple classes. This is why I do not want to create this classes and I would use Hibernata as a "intelligent sql generator" where there is no logic behind CRUD transactions.
Today I tried to discover how I could do this without success, I saw that Hibernate is always looking foor the corresponding class.

For "intelligent" class, however, I like Hibernate and How it works...
are there other tools to do anything like what I need?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 1:58 pm 
Newbie

Joined: Mon Jul 11, 2005 8:34 am
Posts: 12
el_coda wrote:
In my project I want to manage dinamically the persistance layer for simple classes. This is why I do not want to create this classes and I would use Hibernata as a "intelligent sql generator" where there is no logic behind CRUD transactions.

ummm ok? What's so bad about having a class for a table even if it's "simple", small, rarely used or whatever?! When you use Hibernate to retrieve data from that table for instance, you will definitely need an Object/Class to get populated so that you can read the data from it! Aren't you? And as for dynamically doing stuff, you can always use HQL(Hibernate query language, very similar to SQL ANSI), it's really nice! Or you can actually use SQL ANSI itself through Hibernate. I'm new to Hibernate, but the more I work with it the better it gets! I don't know how much you know about it, but once you get the hang of it you're gonna love it!

Quote:
For "intelligent" class, however, I like Hibernate and How it works...
are there other tools to do anything like what I need?

I really don't know... But I strongly suggest you give Hibernate a try!

And errr I wouldn't mind if you rated my posts ;)
I'm really low on credits! lol


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 2:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dont specify a class name and you can persist Map's instead.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 2:54 pm 
Newbie

Joined: Thu Feb 09, 2006 9:20 am
Posts: 3
Hi,
thanks that's good for me.
So I don't have to specify the class, but where? In the hbm.xml file? ... And then I use PersistentClass+Configuration to configure it?

Have you got a link to a code snippet where it s explained how to persist maps? I'm reading the good book "Hibernate in Action" I haven't found something like this ...

Thanks I will investigate on this.
Ivan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 3:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
read the hibernate 3 docs about entity-name.

_________________
Max
Don't forget to rate


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