Here it is Paul,
as you can see the mapping for the field is correct with regards to type
and sql-type, but a length field has been applied to it. That is incorrect
for a text field in SQL.
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false"
assembly="Tubbed.Core" namespace="Tubbed.Core">
<class name="ApplicationLog" table="ApplicationLog"
xmlns="urn:nhibernate-mapping-2.2">
<id name="LogEntryID" column="LogEntryID" type="Int32">
<generator class="identity" />
</id>
<property name="Date" column="Date" type="DateTime">
<column name="Date" />
</property>
<property name="Level" column="Level" length="50" type="String">
<column name="Level" />
</property>
<property name="Logger" column="Logger" length="255" type="String">
<column name="Logger" />
</property>
<property name="Message" column="Message" length="100"
type="StringClob">
<column name="Message" sql-type="text" />
</property>
<property name="Thread" column="Thread" length="50" type="String">
<column name="Thread" />
</property>
</class>
</hibernate-mapping>
Mapping File:
public class ApplicationLogMap : ClassMap<ApplicationLog>
{
public ApplicationLogMap()
{
WithTable("ApplicationLog");
Id(x => x.LogEntryID);
Map(x => x.Date);
Map(x => x.Level).WithLengthOf(50);
Map(x => x.Logger).WithLengthOf(255);
Map(x =>
x.Message).CustomTypeIs("StringClob").CustomSqlTypeIs("text");
Map(x => x.Thread).WithLengthOf(50);
}
}
Alec Whittington
On Tue, Dec 9, 2008 at 7:57 AM, Alec Whittington <[EMAIL PROTECTED]
> wrote:
> Paul,
> thank you, I will get implemented when I get home this evening. Thanks
> for your reply.
>
> Alec Whittington
>
>
>
>
>
> On Tue, Dec 9, 2008 at 12:27 AM, Paul Batum <[EMAIL PROTECTED]> wrote:
>
>> Alec,
>>
>> Its probably worth trying to find out what the generated hbm xml looks
>> like. The PersistenceModel class has a WriteMappingsTo method that you
>> should be able to use. Alternatively you could use the debugger and step
>> your way into the guts and check the xml document when it is created.
>>
>> Post the xml once you have it.. if the type comes up as "text" in the hbm
>> xml then we know the problem is the schema generation. If the type "text"
>> does not appear then we know its a fluent nhibernate bug.
>>
>> Paul Batum
>>
>>
>> On Tue, Dec 9, 2008 at 5:30 PM, Alec Whittington <
>> [EMAIL PROTECTED]> wrote:
>>
>>> No Ideas? This has me stumped so far.
>>>
>>> Alec Whittington
>>>
>>>
>>>
>>>
>>>
>>> On Mon, Dec 8, 2008 at 11:39 AM, Alec Whittington <
>>> [EMAIL PROTECTED]> wrote:
>>>
>>>> Hi all, I realize this might not be the best place to ask, but
>>>> thought I would start here first then move up the stack as needed.
>>>>
>>>> I have a class, ApplicationLog, that I use for logging Log4Net messages.
>>>> One of the properties for the class is "Message". Nothing special, just a
>>>> string.
>>>> I would like to represent this as a text field in the database. My
>>>> mapping for the field is as such:
>>>>
>>>> Map(x => x.Message).CustomTypeIs("StringClob").CustomSqlTypeIs("text");
>>>>
>>>> In the mapping file (shown in the applications text log) I noticed that
>>>> it was correct with the exception that is has a length on it.
>>>>
>>>> When I generate the SQL script, it does not generate that field in the
>>>> table correctly. It generates it as a nvarchar(100) instead of ntext. I am
>>>> sure I am not the only one that has encountered this issue within the
>>>> group.
>>>> I am generating the SQL script against a SQL 2005 Dev Ed database, not
>>>> SQLExpress. Here is the code for generating the SQL file:
>>>>
>>>> [Test]
>>>> public void CreateSchema()
>>>> {
>>>> Configuration cfg = new Configuration().Configure();
>>>> var persistenceModel = new PersistenceModel();
>>>> persistenceModel.addMappingsFromAssembly(
>>>> Assembly.Load("Tubbed.Data"));
>>>> persistenceModel.Configure(cfg);
>>>> new
>>>> SchemaExport(cfg).SetOutputFile(@"c:\tubbed.sql").Create(true, false);
>>>> //new SchemaUpdate(cfg).Execute(true, false);
>>>> }
>>>>
>>>> Here is my mapping file:
>>>>
>>>> public ApplicationLogMap()
>>>> {
>>>> WithTable("ApplicationLog");
>>>>
>>>> Id(x => x.LogEntryID);
>>>>
>>>> Map(x => x.Date);
>>>> Map(x => x.Level).WithLengthOf(50);
>>>> Map(x => x.Logger).WithLengthOf(255);
>>>> Map(x =>
>>>> x.Message)CustomTypeIs("StringClob").CustomSqlTypeIs("text");
>>>> Map(x => x.Thread).WithLengthOf(50);
>>>> }
>>>>
>>>> As stated above, when I look at the mapping file in the log, it appears
>>>> correct, with exception of the length field. All fields look good in the
>>>> SQL script except for Message which comes out as:
>>>>
>>>> Message NVARCHAR(100) NULL
>>>>
>>>> Any help is appreciated.
>>>>
>>>> Thanks,
>>>>
>>>> Alec Whittington
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>> >>
>>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---