Proc je tam to update="false", to znamena, ze se hodnota sloupce nemeni ... pak 
se to neupdatuje v db. Pouze se hodnota
ulozi pri vkladani noveho zaznamu ...

To neznamena, ze by se to nemelo nacitat data ...

Ja tam nic nevidim, co by me prastilo do oci ... rekl bych, ze UserType je v 
poradku, nehazi to nejakou exception behem
startu?

Vlastimil Vávrů napsal(a):
> 
> mapovani je zde:
> 
>         <property name="status" column="status"
>             type="cz.venturia.imagebank.hibernate.UserStatusUserType"
> not-null="true" update="false" />
> 
> 
> 
> 
> Dne Mon, 06 Nov 2006 11:07:16 +0100 Jiří Mareš <[EMAIL PROTECTED]>
> napsal/-a:
> 
>>
>> A jak vypada mapovani ?? Pouzil jsi tvuj user-type jako "type"??
>>
>> Vlastimil Vávrů napsal(a):
>>>
>>>
>>> Zdravím konferenci,
>>>
>>> chci se zeptat zda někdo z vás již pracovat s UserType v Hiberenatu.
>>> Používám jej pro status uživatele. Viz:
>>>
>>> package cz.venturia.imagebank;
>>>
>>> import java.io.Serializable;
>>> import java.util.HashMap;
>>> import java.util.Map;
>>>
>>> public class UserStatus implements Serializable {
>>>     private static final long serialVersionUID = 11 * Long.MIN_VALUE;
>>>
>>>     private String name;
>>>
>>>     public static final UserStatus ENABLED = new UserStatus("ENABLED");
>>>     public static final UserStatus DISABLED = new
>>> UserStatus("DISABLED");
>>>     public static final UserStatus NOT_APPROVED = new
>>> UserStatus("NOT_APPROVED");
>>>     private static final Map INSTANCES = new HashMap();
>>>
>>>     static {
>>>         INSTANCES.put(ENABLED.toString(), ENABLED);
>>>         INSTANCES.put(DISABLED.toString(), DISABLED);
>>>         INSTANCES.put(NOT_APPROVED.toString(), NOT_APPROVED);
>>>     }
>>>
>>>     private UserStatus(String name) {
>>>         this.name = name;
>>>     }
>>>
>>>     public String toString() {
>>>         return name;
>>>     }
>>>
>>>     private Object readResolve() {
>>>         return getInstance(name);
>>>     }
>>>
>>>     public static UserStatus getInstance(String name) {
>>>         return (UserStatus) INSTANCES.get(name);
>>>     }
>>> }
>>>
>>> UserStatusType trida vypada takto:
>>>
>>> package cz.venturia.imagebank.hibernate;
>>>
>>> import java.sql.PreparedStatement;
>>> import java.sql.ResultSet;
>>> import java.sql.SQLException;
>>> import java.sql.Types;
>>>
>>> import net.sf.hibernate.HibernateException;
>>> import net.sf.hibernate.UserType;
>>> import cz.venturia.imagebank.UserStatus;
>>>
>>> public class UserStatusUserType implements UserType {
>>>
>>>     private static final int[] SQL_TYPES = { Types.VARCHAR };
>>>
>>>     public Object deepCopy(Object value) throws HibernateException {
>>>         return value;
>>>     }
>>>
>>>     public boolean equals(Object x, Object y) throws
>>> HibernateException {
>>>         return x == y;
>>>     }
>>>
>>>     public boolean isMutable() {
>>>         return true;
>>>     }
>>>
>>>     public Object nullSafeGet(ResultSet rs, String[] names, Object
>>> owner) throws HibernateException, SQLException {
>>>         String name = rs.getString(names[0]);
>>>         return rs.wasNull() ? null : UserStatus.getInstance(name);
>>>     }
>>>
>>>     public void nullSafeSet(PreparedStatement st, Object value, int
>>> index) throws HibernateException, SQLException {
>>>         if (value == null) {
>>>             st.setNull(index, Types.VARCHAR);
>>>         } else {
>>>             st.setString(index, value.toString());
>>>         }
>>>     }
>>>
>>>     public Class returnedClass() {
>>>         return UserStatus.class;
>>>     }
>>>
>>>     public int[] sqlTypes() {
>>>         return SQL_TYPES;
>>>     }
>>> }
>>>
>>> Zkusil jsem dal breakpointy do vsech metod ve tride UserTypeStatus - pri
>>> startu aplikace se zavola pouze sqlTypes a returnedClass.
>>>
>>> Pri cteni ani ukladani se jiz nevola zadna metoda.
>>>
>>> Zvlastni je, ze pri vytvareni uzivatele (registraci) se status nastavi
>>> (na NOT_APPROVED)
>>>
>>>
>>> Dík za rady.
>>>
>>>
>>
> 
> 
> 
> 

-- 
Jiří Mareš (mailto:[EMAIL PROTECTED])
ČSAD SVT Praha, s.r.o. (http://www.svt.cz)
Czech Republic

Odpovedet emailem