-->
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: How can I get Sets based on unique constraints
PostPosted: Fri Nov 11, 2005 2:35 am 
Beginner
Beginner

Joined: Thu Oct 13, 2005 3:40 pm
Posts: 29
The scenario is:

I have 3 tables STORE, FISCAL_PERIOD, and STORE_DETAIL. The STORE_DETAIL has two columns store_id (pk for STORE table) and fiscal_period_id (pk for FISCAL_PERIOD table). These two columns form a unique constraint in STORE_DETAIL table

I have a class Store that has getStoreDetails() that returns a set. However, I'd like to get storeDeatils for a specific fiscal_period_id. I was hoping that using Artifact Generation, the unique constraint would automatically be created providing me a method to getStoreDetailsByFiscalPeriod(FiscalPeriod fp). It is a mjor performance hit to first getStoreDetails and then using createFilter (that actually creates a copy) to get the list by FiscalPeriod.

Is that true, if not, am I missing something, do I have to write custom code in the generated POJOs to provide this, if so, how would that change the *.hbm.xml

Thanks in advance!

Atul




Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

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

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 9:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you are asking for a DAO finder based on a unique key. Don't know if we can deduce that sensible everytime but maybe it would make sense.

Put usecase in jira

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 10:25 am 
Beginner
Beginner

Joined: Thu Oct 13, 2005 3:40 pm
Posts: 29
Thank you so much, Max. I will add a use case in JIRA.

Can you point me to a DAO finder sample that is similar to my scenario?

Again, thank you for reply. I really appreciate it.

Atul


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 10:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
its in the junit tests.

if you have a named query we create finders for it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 11:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
or use a Hibernate3 dynamic filter


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 11:22 am 
Beginner
Beginner

Joined: Thu Oct 13, 2005 3:40 pm
Posts: 29
Thanks Steve! However the documentation in section 5.4 for Hibernate 3.0.5 says

"Note that the following features are currently considered experimental and may change in the near future."

I believe Dynamic models/filters is one and the same, right?


Atul


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 11:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
no.

http://www.hibernate.org/hib_docs/v3/reference/en/html/filters.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 11:56 am 
Beginner
Beginner

Joined: Thu Oct 13, 2005 3:40 pm
Posts: 29
Thank you! This is really useful.

Atul


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.