473,382 Members | 1,225 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Hibernate : <One-to-one> Filter Required

Consider this scenatio :
I have one-to-one relation between Product and ProductBasic BUT at database level i have one-to-many between
PRODUCT and PRODUCTBASIC tables as history is mainted in the same table :

PRODUCT ----> PID (PK)
PRODUCTBASIC ---> PID (FK), USECODE forms Composite-key

PRODUCT
PID PNAME
1 Pen

PRODUCTBASIC
PID USECODE STARTTIME ENDTIME
1 100 06-MAY-2009 11:00 07-MAY-2009 10:00
1 100 07-MAY-2009 10:00 31-DEC-9999 00:00

Now while querying for ProductBasic, i will always fetch the row which satisfies the condition STARTTIME<CURRENTTIME<ENDTIME
and this will surely return me only one row.

Ideally the generated sql query should be :

select * from PRODUCT product left outer join PRODUCTBASIC productbasic on '100'=productbasic.USETYPE
and product.PID=productbasic.PID
and (
productbasic.STARTTIME<'09-MAY-2009 10:00'
and '09-MAY-2009 10:00'<productbasic.ENDTIME
)
where
product.PID='1'
May 25 '09 #1
6 5236
r035198x
13,262 8TB
1.) You have not posted a question.
2.) If you have a hibernate question better post it in a hibernate forum.
If you have an SQL problem then better post it in the relevant SQL forum.
May 25 '09 #2
This is a hibernate question only.. I want to know what to do in this situation...
Can i post hibernate questions in bytes forum ?
May 25 '09 #3
r035198x
13,262 8TB
You can and you have. You are likely to get more help in a hibernate forum though than in a Java forum. You also never specified a question.
May 26 '09 #4
Have you managed to find a good solution for this problem? I'm now having the exact same issue and trying to understand what is the best way to solve it.
May 5 '10 #5
jkmyoung
2,057 Expert 2GB
What is the specific problem? What are you trying to accomplish, how are you going about it, and what are the results you're getting now?
May 5 '10 #6
HI,
The problem is i want that certain conditions to be always applied for a particular one-to-one association. Filters are meant for this in hibernate but we cant apply filters to one-to-one associations in hibernate.

I implemented this functionality myself and tried to contribute this to Hibernate @ Hibernate Jira site but i am not satisfied with their response.
See this link :
http://opensource.atlassian.com/proj...rowse/HHH-4026
May 9 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: JDPope | last post by:
I have a situation which I cannot get a good lead on how to resolve. One of the applications I support uses the Hibernate software to generate SQL. The app is JAVA with JDBC. In testing the users...
1
by: chandukandula | last post by:
Hi Already my application in Struts using JDBC.At present my application is implemented in Struts with hibernate So i am not changing the SQL queries converting to the like this String...
6
rsrinivasan
by: rsrinivasan | last post by:
Hi all, I am using Hibernate framework in my project. This is my configuration in my "hibernate.cfg.xml" file. <property name="hibernate.c3p0.max_size">25</property> <property...
3
by: altafur | last post by:
hi, i am using java with hibernate . i want to run a hibernate order by query thru java. i have written the query in hibernate.hbm.xml file. the query is as follows: query: SELECT distinct...
0
by: neuraljay | last post by:
hi everyone. I am trying to build a jsp using webwork, hibernate and mysql. And right now I am doing its unit testing. Everytime I run the test I am getting this error: Error JDBC exception on...
1
by: ashi1290 | last post by:
I am getting this error..... Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:120)...
0
by: CatchSandeepVaid | last post by:
We all know that one-to-one associations are non-lazly fetched but during this fetching the filters are not applied. I debugged hibernate code and found that hibernate finally calls...
1
by: CatchSandeepVaid | last post by:
Suppose i have one-to-one association between Product and ProductBasic. and we have applied filter on ProductBasic Class. I have applied this filter as in Java side we have one-to-one relationship...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.