-->
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: find all the entities
PostPosted: Sun Jan 18, 2009 8:14 am 
Newbie

Joined: Thu Jul 26, 2007 5:12 am
Posts: 14
Location: Nepal
Dear all,

how can I get all the classes annotated with @Entity?
all I could think of is scan all the classes and check it with isAnnotationPresent().. isnt there any easy way to do this??


-FriedDust

_________________
:: there are 10 types of people in this world...1 who understands binary and the other 1 who does not ::


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 9:11 am 
Newbie

Joined: Fri Jan 09, 2009 4:31 am
Posts: 9
maybe ...getSessionFactory().getStatistics().getEntityNames() ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 10:25 am 
Newbie

Joined: Thu Jul 26, 2007 5:12 am
Posts: 14
Location: Nepal
thanks for the reply man4j.

Im using JPA + Hibernate + Tomcat + Spring
I tried this code,

Code:
Session sess  = ((Session) getJpaTemplate().getEntityManagerFactory().createEntityManager().getDelegate());
           
System.out.println("--< " + sess.getStatistics().getEntityKeys());


it returns an empty set.

I have even set the generate_statistics = true

Code:
<property name="jpaProperties">
      <value>
        hibernate.generate_statistics=true
        hibernate.archive.autodetection=class
        </value>
    </property>



any help??

_________________
:: there are 10 types of people in this world...1 who understands binary and the other 1 who does not ::


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 10:31 am 
Newbie

Joined: Thu Jul 26, 2007 5:12 am
Posts: 14
Location: Nepal
im sorry, i found out the problem.

I did sess.getStatistics() instead of ess.getSessionFactory().getStatistics()

:-)

_________________
:: there are 10 types of people in this world...1 who understands binary and the other 1 who does not ::


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 11:24 am 
Regular
Regular

Joined: Tue Jun 03, 2008 1:12 pm
Posts: 84
Location: germany
all entites are derived from Object-Class:

So you can say in HQL:

"from Object"


(Please rate, I have no points anymore)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 12:08 am 
Newbie

Joined: Thu Jul 26, 2007 5:12 am
Posts: 14
Location: Nepal
nimo23 wrote:
all entites are derived from Object-Class:

So you can say in HQL:

"from Object"


(Please rate, I have no points anymore)


sorry nimo23,
your code didnt work. it throws org.hibernate.hql.ast.QuerySyntaxException

_________________
:: there are 10 types of people in this world...1 who understands binary and the other 1 who does not ::


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 5:15 am 
Regular
Regular

Joined: Tue Jun 03, 2008 1:12 pm
Posts: 84
Location: germany
do this HQL-Query:

"from java.lang.Object o"


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.