-->
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.  [ 2 posts ] 
Author Message
 Post subject: can auto save "Set" property when saving a object
PostPosted: Sun May 01, 2005 3:52 pm 
Regular
Regular

Joined: Sat Apr 10, 2004 8:39 pm
Posts: 84
can auto save "Set" property when saving a object?

for example:


Set authorities = new CopyOnWriteArraySet();
for (int i=0; i<model.getRoles().length; i++) {
AuthoritiesId authoritiesId = new AuthoritiesId();
authoritiesId.setUserDetails(userDetails);
authoritiesId.setRoleDefiniens(roleDefiniensDao.loadByPrimaryKey(model.getRoles()[i]));
Authorities authority = new Authorities(authoritiesId);


authorities.add(authority);
}
userDetails.setSetOfAuthorities(authorities);

session.save(userDetails);


Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping
DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!--
    Auto-generated mapping file from
    the hibernate.org cfg2hbm engine
-->
  <class name="demos.UserDetails"
  table="KYDA_USER_DETAILS">
    <id name="relId" type="java.lang.Integer">
      <column name="REL_ID" not-null="true" unique="true"
      sql-type="INTEGER" />

      <generator class="native">
          <param name="sequence">kyda_user_details_rel_id</param>
      </generator>
    </id>

    <property name="username" type="java.lang.String">
      <column name="USERNAME" length="50" not-null="true"
      unique="true" sql-type="VARCHAR" />
    </property>

    <property name="realname" type="java.lang.String">
      <column name="REALNAME" length="50" not-null="true"
      sql-type="VARCHAR" />
    </property>

    <property name="password" type="java.lang.String">
      <column name="PASSWORD" length="50" not-null="true"
      sql-type="VARCHAR" />
    </property>

    <property name="accountNonExpired" type="java.lang.Boolean">
      <column name="ACCOUNT_NON_EXPIRED" not-null="true"
      sql-type="BOOLEAN" />
    </property>

    <property name="credentialsNonExpired" type="java.lang.Boolean">
      <column name="CREDENTIALS_NON_EXPIRED" not-null="true"
      sql-type="BOOLEAN" />
    </property>

    <property name="accountNonLocked" type="java.lang.Boolean">
      <column name="ACCOUNT_NON_LOCKED" not-null="true"
      sql-type="BOOLEAN" />
    </property>

    <property name="enabled" type="java.lang.Boolean">
      <column name="ENABLED" not-null="true" sql-type="BOOLEAN" />
    </property>
<!--
    <property name="authorities" type="java.lang.String">
      <column name="AUTHORITIES" length="1024" not-null="true"
      sql-type="VARCHAR" />
    </property>
-->

    <set name="setOfUserGroupRelation">
      <key>
        <column name="USER_REL_ID" not-null="false"
        unique="true" />
      </key>

      <one-to-many
      class="demos.UserGroupRelation" />
    </set>

    <set name="setOfAuthorities">
      <key>
        <column name="REL_ID" not-null="false" unique="true" />
      </key>

      <one-to-many
      class="demos.Authorities" />
    </set>

  </class>
</hibernate-mapping>

_________________
I am the creatxr of world.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 01, 2005 4:14 pm 
Regular
Regular

Joined: Sat Apr 10, 2004 8:39 pm
Posts: 84
I've tried. I used method saveOrUpdate.

It seems it can save a new Object in Set


but it can't delete Object. if I removed it from the Set

_________________
I am the creatxr of world.


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

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.