Hibernate : <One-to-one> Filter Required

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CatchSandeepVaid
    New Member
    • Apr 2009
    • 15

    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<CURRE NTTIME<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'=productba sic.USETYPE
    and product.PID=pro ductbasic.PID
    and (
    productbasic.ST ARTTIME<'09-MAY-2009 10:00'
    and '09-MAY-2009 10:00'<productb asic.ENDTIME
    )
    where
    product.PID='1'
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    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.

    Comment

    • CatchSandeepVaid
      New Member
      • Apr 2009
      • 15

      #3
      This is a hibernate question only.. I want to know what to do in this situation...
      Can i post hibernate questions in bytes forum ?

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        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.

        Comment

        • fabrikant
          New Member
          • May 2010
          • 1

          #5
          &lt;One-to-one&gt; Filter Required

          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.

          Comment

          • jkmyoung
            Recognized Expert Top Contributor
            • Mar 2006
            • 2057

            #6
            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?

            Comment

            • CatchSandeepVaid
              New Member
              • Apr 2009
              • 15

              #7
              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 :

              Comment

              Working...