Announcement Announcement Module
Collapse
No announcement yet.
primary key problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • primary key problem

    Hi
    I've table with id, appid and some more columns
    ID here is this table ID which increments by default. whereas appid is the one whoch has one-tomany relationship with otehr tables

    my hbm.xml is like this while reading data it's ok but while writing data I'm getting error as hsql created tried to set ID which is automatically generated key. Can somebody pelase help me.

    Table a hbm.xml

    Code:
    <hibernate-mapping>
        <class name="AccountOpenVO" table="ACCOPEN">
        
         <id name="appid" column="appid" type="java.lang.Integer" unsaved-value="null">
    </id> 
        <property name="Id" column="id" type="java.lang.Integer" not-null="true" />
         <set name="customers"   table="ACCCUST" lazy="false">
            <key column="dia_accopenid" />
                <one-to-many  class="AccountCustVO"  />
             </set> 
          <set name="products"   table="ACCPROD" lazy="false">
            <key column="dia_accopenid" />
                <one-to-many class="AccountProdVO" />
             </set>
                <property name="runno"  column="runind"  type="java.lang.Integer" not-null="true"/>
    </class>

  • #2
    If you have an association, then you should map this rather than the property.
    http://www.hibernate.org/hib_docs/v3...ional-join-12m
    Last edited by karldmoore; Aug 29th, 2007, 11:15 AM.

    Comment


    • #3
      Originally posted by karldmoore View Post
      If you have an association, then you should map this rather than the property.
      http://www.hibernate.org/hib_docs/v3...ional-join-12m
      Hi
      in my case it is not the primary key having one-to-many relation. how do i declare the set with another column.
      for eg., here it is "appid" having relation with other table column "accopenid"
      please show me some example.

      thanks

      Comment


      • #4
        use the property-ref option on the key element.

        Comment


        • #5
          Hi Here is the more clear picture of my mapping problem


          in my case it is not the primary key having one-to-many relation. how do i declare the set with another column.
          for eg., here it is "appid" in table A(which is non pri key) having relation with other table column "accopenid" which is again non-primary key in tableB
          please show me some example.

          thanks

          Comment

          Working...
          X