-->
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: Selectively updating properties
PostPosted: Wed Sep 01, 2004 6:38 pm 
Newbie

Joined: Wed Sep 01, 2004 5:56 pm
Posts: 2
Hibernate version:
2.1.6

Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
   PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="org.rhavyn.communities.services.core">
   <class name="User" table="users">
      <id name="id">
         <column name="user_id" sql-type="char(32)"/>
         <generator class="uuid.hex"/>
      </id>
      <property name="username" access="field" update="false" not-null="true"
         unique="true" length="20"/>
      <component name="password" class="Password">
         <property name="hashedPassword" access="field">
            <column name="password" not-null="true" sql-type="char(32)"/>
         </property>
      </component>
      <property name="admin" not-null="true" column="is_admin"/>
      <property name="firstName" not-null="true" column="first_name" length="50"/>
      <property name="lastName" not-null="true" column="last_name" length="50"/>
      <property name="email" not-null="true" length="100"/>
   </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
N/A

Full stack trace of any exception that occurs:
N/A

Name and version of the database you are using:
MySQL 4.0.x and Postgres 7.3.x

Debug level Hibernate log excerpt:
N/A

Hello,

In my application I have an entity mapped as above. There is certain business logic and security constraints which need to be validated before an update can occur. For example, the admin field should only be updatable by someone who is currently an admin and whenever the email field is updated, a confirmation email needs to be sent to the new address. What I was trying to avoid was to have to select a copy of the object out of the database and then hand comparing the fields. I looked into making User abstract, not provided setters for email and admin, and providing a concrete subclass in the business layer which would have access to those fields. That feels like a dirty solution to me, though, but I am willing to hear reasons why it isn't. Is there a generally accepted method of mapping something like that in the Hibernate community?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 7:49 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
http://www.hibernate.org/hib_docs/refer ... alidatable

http://www.hibernate.org/hib_docs/refer ... -lifecycle

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.