If you have existing mappings using the StringClob type (or a certain type), you can use a custom Driver to do the same work without touch existing mappings.
-- Fabio Maulo El 05/10/2010, a las 03:32, cremor <[email protected]> escribió: > No, I'm not generating the DB with NHibernate. The DB already exists > and the changes I can make to it are limited. Adding a default value > to the column in the DB is not possible. > > But I found a solution. I implemented an IUserType with the following > code: > > public void NullSafeSet(IDbCommand cmd, object value, int index) > { > string sValue = value as string; > > if (sValue == String.Empty) { > OracleCommand oCmd = cmd as OracleCommand; > > if (oCmd != null) { > oCmd.Parameters[index].OracleDbType = > OracleDbType.Clob; > oCmd.Parameters[index].Value = String.Empty; > } > } else { > NHibernateUtil.String.NullSafeSet(cmd, value, index); > } > } > > > On 4 Okt., 15:10, Fabio Maulo <[email protected]> wrote: >> Ups sorry.... 3 chats-mails-language-mixing >> 1. the type of the property is wrong >> 2. you are not generating the DB through NH and/or, over all, you are not >> comparing what NH thinks you have in schema with what you already have >> >> >> >> On Mon, Oct 4, 2010 at 8:46 AM, Fabio Maulo <[email protected]> wrote: >>> 1. el type de la property es incorrecto >>> 2. lo que te pase es porque no está generando la base con NH y/o sobre todo >>> no estas comparando lo que NH piensa que está con lo que vos pusiste. >> >>> On Mon, Oct 4, 2010 at 3:55 AM, cremor <[email protected]> wrote: >> >>>> Thanks for your fast response, but I can't get this to work. >> >>>> My Dialect (the method is called during startup, so it should be >>>> configured correctly): >>>> public class ExtendedOracleDialect : Oracle10gDialect { >>>> protected override void RegisterFunctions() { >>>> base.RegisterFunctions(); >>>> RegisterFunction("empty_clob", new >>>> NoArgSQLFunction("empty_clob", NHibernateUtil.String, true)); >>>> } >>>> } >> >>>> My mapping (inside a double nested-composite-element, but I hope this >>>> doesn't change anything): >>>> <property name="Formatted" type="System.String, mscorlib, >>>> Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> >>>> <column name="ERSETZUNG_FORMATIERT" >>>> default="empty_clob()" /> >>>> </property> >> >>>> But the generated insert statements are still using '' for >>>> String.Empty and NULL for null instead of empty_clob(), which I need >>>> in both cases. >> >>>> On 1 Okt., 14:58, Fabio Maulo <[email protected]> wrote: >>>>> After register the empty_clob() function in your own dialect, you can >>>> try >>>>> using the "default" attribute of <column>. >> >>>>> On Fri, Oct 1, 2010 at 9:53 AM, cremor <[email protected]> wrote: >>>>>> Is there a way to tell NHibernate to replace all values of empty >>>>>> strings with the Oracle function empty_clob() in inserts/updates to a >>>>>> specific column? >> >>>>>> I'd need this to insert a empty string to a CLOB column which has a >>>>>> NOT NULL constraint (Oracle treats empty strings the same as NULLs, so >>>>>> it tries to insert a NULL to my CLOB column). >> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>> Groups >>>>>> "nhusers" group. >>>>>> To post to this group, send email to [email protected]. >>>>>> To unsubscribe from this group, send email to >>>>>> [email protected]<nhusers%[email protected]> >>>> <nhusers%[email protected]<nhusers%[email protected]> >> >>>>>> . >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/nhusers?hl=en. >> >>>>> -- >>>>> Fabio Maulo >> >>>> -- >>>> You received this message because you are subscribed to the Google Groups >>>> "nhusers" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]<nhusers%[email protected]> >>>> . >>>> For more options, visit this group at >>>> http://groups.google.com/group/nhusers?hl=en. >> >>> -- >>> Fabio Maulo >> >> -- >> Fabio Maulo > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
