-->
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.  [ 15 posts ] 
Author Message
 Post subject: addResource() using wildcard for class names
PostPosted: Thu May 17, 2007 5:27 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
is there a way to use wildcard for all *.class in a package when doing
cfg.addResource()?

adding classes one by one is difficult in my set up.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 19, 2007 1:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no, but you can add a directory or jar of mapping files.

Have you considered using Annotations/JPA with that autodiscovery will work for you - even for hbm.xml files.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 09, 2007 7:52 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
I am back on this topic again, because now I am concerned about deployment on Tomcat.

When deploying with a .war in a co-hosted environment, you generally do not have tight control on the absolute file path. Referencing .xml embedded in a jar file is also not so convenient (at least it requires a path change compared to the development environment).

shouldn't there be a addJar() which takes just the jar file name instead of File, since the JVM can always find the jar file from its classpath.

Is this actually a show stopper for deploying with .war? how do people get around it?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 4:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it's called JPA which standardizes/enables automatically scanning of the classpath.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 12:58 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
just because it is a standard, doesn't mean it meets developer's needs.

do you have a solution for the concerns I raised?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 1:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
what part of use JPA API's is not clear ? :)

You can use hibernate entity manager to do what you want - e.g. scan the classpath for entities.

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 1:21 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
well, I looked at all the methods for HibernateFactory. which api scans the classpath?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 11, 2007 2:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
http://www.hibernate.org/hib_docs/entit ... ml_single/

// Use persistence.xml configuration
EntityManagerFactory emf = Persistence.createEntityManagerFactory("manager1")
EntityManager em = emf.createEntityManager(); // Retrieve an application managed entity manager

Session s = (Session)em.getDelegate();

and have whatever hibernate specific fun you want.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 14, 2007 6:34 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
ic, you are suggesting pulling all the entitymanager and annotation stuff to get this one additional feature. I gather it means there is no way to scan the classpath using only the core.

that's a bit much for adding one function. it would be very very nice if this feature can be added in the future in the core. here is my vote!!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 14, 2007 6:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh - so you would rather have us add more bulk to the core which anyway is 90% of what "all" the entitymanager and annotation stuff is.

For you it would mean many fewer lines of configuration for adding 2-3 *small* jars to your project....can't understand why that is something to avoid.

btw. you are more than welcome to just take the code in entitymanager to do the autoscanning and then just use that to initialize hibernate - its opensource (and would end up with the same "weight" IMO).

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 15, 2007 3:34 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
I suggest adding the feature because

1. I did not think this feature in terms of "bulk", like 2-3 jars and a configuration file are more likely considered a bulk for deployment bundling.

2. The Configuration class has all the relevant methods, addClass, addJar, addFile. it seems addJar from the classpath would just complete the set very nicely.

I don't know all of the api's needed to accomplish this off the top of my head. I just imagine it isn't exact a bulk. Of course, if this represents a substantial effort, as you are suggesting, then mine is not a good suggestion.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 16, 2007 3:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i'm saying it is not trivial and adding yet another way of scanning (and configuration of it) is not something that is trivial nor really wanted.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 16, 2007 1:27 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
yes, you reminded me the need of another configuration file. which what I am trying to eliminate. Right now, I use a properties file to indicate where the hbm files are to Configuration. replacing that with a configuration file for EntityManager gets me no where.

But thanks for pointing out the options.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 16, 2007 2:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh - you would remove the need for that properties file if you used autoscanning...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 16, 2007 5:04 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
I know. But using autoscan I would need to add persistence.xml.

save one, add one, there is hardly any incentive to make the change.


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