-->
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.  [ 1 post ] 
Author Message
 Post subject: Column Transformer not workinf on Select
PostPosted: Wed Mar 13, 2013 7:18 am 
Newbie

Joined: Wed Mar 13, 2013 6:59 am
Posts: 3
I have 2 tables related by a column in Table1 which stores the Id of the object from Table 2 with the following format:

tableId:objectId -> Where tableId is a numeric value representing the id of Table 2 (not important for what I need) and objectId is a numeric value which is the id of the object in Table 2, very same as stored on column Id on Table 2.

This kind of ralations on BD can't be changed (they are mandatory for the project, though it would be much easier to have simple foreign keys).

Code:
CREATE TABLE TABLE1_CGRAD
(
  ID                    NUMBER(8)               NOT NULL,
  CLASS_ID              NUMBER(4),
  DESCRIPTION           VARCHAR2(30 BYTE),
  ID_FP               VARCHAR2(13 BYTE),
)

CREATE TABLE TABLE2_FPR
(
  ID                  NUMBER(8)                 NOT NULL,
  CLASS_ID            NUMBER(4),
  DESCRIPTION         VARCHAR2(30 BYTE),
  OFFSET              NUMBER(4),
  COND                VARCHAR2(13 BYTE),
)


So in TABLE1_CGRAD.ID_FP = SOMENUMBER:TABLE2_FPR.ID

I have configured Hibernate xml with a custom read and write for the column TABLE1_CGRAD.ID_FP:

Code:
<hibernate-mapping package="com.pck.entities">
    <class name="CGrad" table="TABLE1_CGRAD">
       <id name="id" column="id">
            <generator class="native"/>
        </id>
        <property name="classId" column="class_id"/>
        <property name="description" column="descripcion"/>
      <many-to-one name="fp" class="com.pck.entities.Fpr"  unique="true" fetch="select" cascade="save-update">         
         <column name="id_fp"
            write="concat('3090:', ?)"
            read="SUBSTR(id_fp, INSTR(id_fp, ':', -1, 1)+1, LENGTH(id_fp)- INSTR(id_filtro_pir, ':', -1, 1))" />
      </many-to-one>
    </class>
</hibernate-mapping>


When I make hibernate use 2 select to get the two related objects from both tables, It works fine. But if I try to make hibernate use a Join Select to get the two objects at the same time, the custom read formula for the column id_fp is not applied (it makes the query simply with Table1.id_fp=Table2.id), so the select doesn't work. The same when trying to make a subcriteria for the column. Any idea why is this happenning?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.