-->
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: getColumnIterator() or getPrimaryKey() always return null
PostPosted: Tue Mar 30, 2004 1:24 pm 
Beginner
Beginner

Joined: Tue Mar 23, 2004 8:40 pm
Posts: 22
<!--
Question for Hibernate 2.1.2
-->
I would like to get the column name(s) (via method getColumnIterator() or getPrimaryKey())) from the child table (i.e. map) to create my dynamic criterion, however, I could get back the table name only, am I missing sth?

Code:
        Criterion criterion = Expression.sql("exists (select 1 from *child_table* where {alias}.id = *child_table*.*child_key_column* and *child_table*.*child_element_column* like upper(?))", s, Hibernate.STRING);
        _criteria.add(criterion);


Thanks in advance!


<!--
CompanyVO.hbm.xml
-->

Code:
  <class name="CompanyVO"
     table="company"
     optimistic-lock="version">

    <id name="objId" type="string">
      <column name="objId" length="16"/>
      <generator class="uuid.hex"/>
    </id>

    <version name="revNo" column="revNo" type="long"/>

    <property name="clientId" column="clientObjId" type="string"/>
    <property name="code" column="code" type="string"/>
    <property name="note" column="note" type="string"/>

    <component name="owner" class="Owner">
      <property name="id" column="ownerobjid" type="string"/>
    </component>
    <component name="auditInfo" class="AuditInformation">
      <property name="creation" column="CreateDate" type="timestamp"/>
      <property name="lastEdited" column="LastEditDate" type="timestamp"/>
      <property name="createdByObjId" column="CreateBy_PersonObjId" type="string"/>
      <property name="editedByObjId" column="LastEditBy_PersonObjId" type="string"/>
    </component>

    <many-to-one name="status" column="statusObjId" class="Status"/>

    <map name="otherProperties" table="company_oproperty" lazy="false">
      <key column="companyobjid"/>
      <index column="key" type ="string"/>
      <element column="value" type="string"/>
    </map>
    <map name="descriptions" table="company_descr" lazy="false">
      <key column="companyobjid"/>
      <index column="localeinfoobjid" type ="string"/>
      <element column="description" type="string"/>
    </map>

  </class>


<!--
Code
-->
Code:
      Iterator collectionMappings = configuration.getCollectionMappings();
      while (collectionMappings.hasNext()) {
        Object o = collectionMappings.next();
        if (o instanceof Collection) {
          Collection collection = (Collection) o;
          log.info("Table name: "+collection.getCollectionTable().getName());
          Iterator columnIterator = collection.getCollectionTable().getColumnIterator();
          while (columnIterator.hasNext()) {
            Object o1 = columnIterator.next();
            log.info("Column name: "+o1);
          }
          log.info("Primary key: "+collection.getCollectionTable().getPrimaryKey());
        }
      }




<!--
Console output
-->
Code:
2004 Mar 30 10:06:38  INFO [ApplicationServerThread](PersistenceMetainfoManager loadPersistenceMetainfo 39) - Table name: company_descr
2004 Mar 30 10:06:53  INFO [ApplicationServerThread](PersistenceMetainfoManager loadPersistenceMetainfo 45) - Primary key: null


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.