[fluent-nhib] Re: How to get a post into this forum?

2011-08-03 Thread Paul Batum
Apologies, this forum is just moderated by myself and James. We are not as 
on the ball as we used to be. I'm going to try to change my mail rules so 
that I see moderation emails more often.

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/fluent-nhibernate/-/3FBS9Q_1NuAJ.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.



[fluent-nhib] Re: Prevent Reference from Updating

2011-08-03 Thread Wildjoe182
Ok, so the key was the enum.

People who suggest mapping an enum as below, are wrong in doing so.

public sealed class ProductCategoryMap : ClassMap
{

Table("ProductCategory");
Id(x => x.Code)
 .GeneratedBy.Assigned();

Map(x => x.Name).Not.Nullable();

Map(x => x.Type, "CatType")
.CustomType(typeof(Int32)) //!!!Don't ever do this
.Not.Nullable();

}

Problem
Everything seems fine on the surface, but everytime a ProductCategory
is loaded it is immediately marked as Dirty.
Although the values remain the same, when I committed my transaction,
all loaded Product Categories were being updated.

Conclusion
Fluent treats Enums as strings, great! All my *new* tables will work
fine. But I'm reading a legacy table where it is stored as an int.

I don't want to change the Fluent NHibernate convention. Let Fluent
treat Enums as strings. But in some cases, I want them as integers.
This is why I created an IUserType. Since I don't automap (at all),
this was best for me.


Solution
---
Using the BaseImmutableUserType as seen here:
http://darrell.mozingo.net/2009/02/10/generic-nhibernate-user-type-base-class/
Using this logic to change an int into an generic Enum (which is not
directly supported by c# because Enums are not classes):
http://stackoverflow.com/questions/1189144/c-non-boxing-conversion-of-generic-enum-to-int

I created the following class:

public class EnumAsInt : BaseImmutableUserType
{
public static int Identity(int x) { return x; }

public override object NullSafeGet(IDataReader rs, string[]
names, object owner)
{
//treat for the possibility of null values
var result = (int)NHibernateUtil.Int32.NullSafeGet(rs,
names[0]);

Type enumType = typeof(T);
if (!enumType.IsEnum)
{
throw new
NotSupportedException("..Infrastructure.NullSafeGet  must be an
Enum.");
}

Func identity = Identity;
var x = Delegate.CreateDelegate(typeof(Func),
identity.Method) as Func;
return x.Invoke(result);
}

public override void NullSafeSet(IDbCommand cmd, object value,
int index)
{
//I expected an Enum, but somehow, this never seems to be
true.
if (value != null && value.GetType() == typeof(Enum))
{
int val = (int)value;
NHibernateUtil.Int32.NullSafeSet(cmd, val, index);

return;
}

//It seems like it already an int once it gets to here.
NHibernateUtil.Int32.NullSafeSet(cmd, value, index);
}

public override SqlType[] SqlTypes
{
get
{
SqlType[] types = new SqlType[1];
types[0] = new SqlType(DbType.Int32);
return types;
}
}
}

My mapping class
public sealed class ProductCategoryMap : ClassMap
{

Table("ProductCategory");
Id(x => x.Code)
 .GeneratedBy.Assigned();

Map(x => x.Name).Not.Nullable();

Map(x => x.Type, "CatType")
.CustomType>()
.Not.Nullable();

}
---

So far so good. This worked for me.

On Aug 1, 1:41 pm, Wildjoe182  wrote:
> Let me start by saying I saw plenty of posts with my problem, but in
> reverse. However, I wasn't able to solve my problem by reading those
> posts. Thanks in advanced for any guidance.
>
> I have a relationship between two entities Product and ProductCategory
> with table resembling the following:
>
> Product
> 
> Id int identity primary key not null
> Name varchar(20) not null
> FK_ProdCat varchar(12) null
>
> ProductCategory
> 
> Code varchar(12) primary key not null
> Name varchar(20) not null
> CatType int not null
>
> - A product only has one category.
> - The category could be null
> - The category could no longer exist. (bad DB)
> - The type column is an Enum in the code (don't know if that's
> important)
>
> My Mapping Classes
> -
> public sealed class ProductMap : ClassMap
> {
>
> Table("Product");
> Id(x => x.Id)
>  .GeneratedBy.Identity();
>
> Map(x => x.Name).Not.Nullable();
>
> References(x => x.ProductCategory)
>  .Column("FK_ProdCat")
>  .Cascade.None()
>  .Nullable()
>  .Not.LazyLoad() //always get
>  .Fetch.Join()
>  .NotFound.Ignore(); //could be bad data
>
> }
>
> public sealed class ProductCategoryMap : ClassMap
> {
>
> Table("ProductCategory");
> Id(x => x.Code)
>  .GeneratedBy.Assigned();
>
> Map(x => x.Name).Not.Nullable();
>
> Map(x => x.Type, "CatType").Not.Nullable();
>
> }
>
> The problem I have is that when I save a Product, the ProductCategory
> is being updated.
> I added the Cascade.None as an afterthought, but it didn't change
> anything.
>
> I see the Update statement being executed in the SQL Server Profiler,
> so I'm not crazy. :)
>
> Extra info
> --
> Before saving the Product, I retrieve the

Re: [fluent-nhib] Re: How do I set the size of a int property ???

2011-08-03 Thread Carl Bussema
If your backing database type supports unsigned (MySQL), could that be the
problem? It's generating int(10) so that it has enough precision for the
extra sign bit? I haven't worked with NH & MySQL, so I'm just guessing
wildly.

Carl

On Wed, Aug 3, 2011 at 8:43 AM, Will Green wrote:

> Just a thought: might that precision be too great for a 32 bit
> integer? Might you instead need the .NET data type be an 64 bit int?
>
> On Aug 2, 10:42 am, Banzai  wrote:
> > Hi All
> >
> > I am having some difficulty changing the default size of a int
> > property in my mapping
> >
> > Id(x => x.IdB).Column("IDB").Precision(11).GeneratedBy.Assigned();
> >
> > When Fluent Nhibernate creates my schema the column is created as a
> > NUMBER (10) and I'm expecting NUMBER 11)
> > Any ideas what I may be doing wrong?
> >
> > Thanks a lot.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Fluent NHibernate" group.
> To post to this group, send email to fluent-nhibernate@googlegroups.com.
> To unsubscribe from this group, send email to
> fluent-nhibernate+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/fluent-nhibernate?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.



Re: [fluent-nhib] NuGet Package FluentNHibernate

2011-08-03 Thread Kurt Johnson
What does your assembly redirect look like?

On Wed, Aug 3, 2011 at 1:47 AM, KSig  wrote:

> I'm adding FluentNHibernate to my .Net 4.0 MVC 3.0 application via the
> NuGet package.
>
> Run-time I get the following error:
>
> System.IO.FileLoadException: Could not load file or assembly
> 'NHibernate, Version=3.2.0.4000, Culture=neutral,
> PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The
> located assembly's manifest definition does not match the assembly
> reference. (Exception from HRESULT: 0x80131040) --->
> System.IO.FileLoadException: Could not load file or assembly
> 'NHibernate, Version=3.1.0.4000, Culture=neutral,
> PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The
> located assembly's manifest definition does not match the assembly
> reference. (Exception from HRESULT: 0x80131040)
> ..()
>
> Is this a known issue? Or am I missing something?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Fluent NHibernate" group.
> To post to this group, send email to fluent-nhibernate@googlegroups.com.
> To unsubscribe from this group, send email to
> fluent-nhibernate+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/fluent-nhibernate?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.



[fluent-nhib] Re: How to get a post into this forum?

2011-08-03 Thread Samyem Tuladhar
You just have to wait long enough for the moderator to accept your post. 
This project does not appear to be active enough for a quick turnaround to 
forum posts.

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/fluent-nhibernate/-/r57Zh5SveiIJ.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.



[fluent-nhib] FluentNHibernate nuget package dependencies and NHibernate 3.2

2011-08-03 Thread Andris Kurmis
According to Fabio Maulo, "#NHibernate 3.2 package will be the only 
available option in #nuget (no more NHibernate.Castle nor NHibernate.LinFu 
nor NHibernate.Spring)".
Will there be an update in FlunetNHibernate's nuget package to set 
dependency to NHibernate only?

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/fluent-nhibernate/-/ynG-sR9ruN8J.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.



[fluent-nhib] NuGet Package FluentNHibernate

2011-08-03 Thread KSig
I'm adding FluentNHibernate to my .Net 4.0 MVC 3.0 application via the
NuGet package.

Run-time I get the following error:

System.IO.FileLoadException: Could not load file or assembly
'NHibernate, Version=3.2.0.4000, Culture=neutral,
PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040) --->
System.IO.FileLoadException: Could not load file or assembly
'NHibernate, Version=3.1.0.4000, Culture=neutral,
PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
..()

Is this a known issue? Or am I missing something?

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.



[fluent-nhib] Re: FYI: NHibernate 3.2.0GA released!

2011-08-03 Thread Samyem Tuladhar
Whats the plan to update FNH to work against nhibernate 3.2 out of the box?

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/fluent-nhibernate/-/uRm6qoDR_ogJ.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.



[fluent-nhib] Re: How do I set the size of a int property ???

2011-08-03 Thread Will Green
Just a thought: might that precision be too great for a 32 bit
integer? Might you instead need the .NET data type be an 64 bit int?

On Aug 2, 10:42 am, Banzai  wrote:
> Hi All
>
> I am having some difficulty changing the default size of a int
> property in my mapping
>
> Id(x => x.IdB).Column("IDB").Precision(11).GeneratedBy.Assigned();
>
> When Fluent Nhibernate creates my schema the column is created as a
> NUMBER (10) and I'm expecting NUMBER 11)
> Any ideas what I may be doing wrong?
>
> Thanks a lot.

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.



[fluent-nhib] How to map Oracle LONG columns?

2011-08-03 Thread Klaus
Hello,

i have to use an old legacy Oracle database. In one table i have to
store the content of  accounting records. The column where i have to
store the records is of type LONG. Internally the accounting records
are stored as strings in XML format. As long as the accounting records
aren't longer than 4.000 bytes everything works fine. But if they are
bigger, i got an Oracle error "ORA-01461 can bind a LONG value only
for insert into a LONG column". When i copy my xml to the clipboard
and insert it via TOAD directly into the table everything works.

Can anyone help me to solve this problem?

Best Regards
Klaus

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.



[fluent-nhib] How to get a post into this forum?

2011-08-03 Thread Klaus
I posted a message in this forum around a week ago where i asked how
to map Oracle LONG columns. Until today i didn't see the posting nor
get an info from the moderators why it isn't posted. So what do i have
to do to post into this forum???

Regards
Klaus

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.



[fluent-nhib] Prevent Reference from Updating

2011-08-03 Thread Wildjoe182
Let me start by saying I saw plenty of posts with my problem, but in
reverse. However, I wasn't able to solve my problem by reading those
posts. Thanks in advanced for any guidance.

I have a relationship between two entities Product and ProductCategory
with table resembling the following:

Product

Id int identity primary key not null
Name varchar(20) not null
FK_ProdCat varchar(12) null

ProductCategory

Code varchar(12) primary key not null
Name varchar(20) not null
CatType int not null

- A product only has one category.
- The category could be null
- The category could no longer exist. (bad DB)
- The type column is an Enum in the code (don't know if that's
important)

My Mapping Classes
-
public sealed class ProductMap : ClassMap
{

Table("Product");
Id(x => x.Id)
 .GeneratedBy.Identity();

Map(x => x.Name).Not.Nullable();

References(x => x.ProductCategory)
 .Column("FK_ProdCat")
 .Cascade.None()
 .Nullable()
 .Not.LazyLoad() //always get
 .Fetch.Join()
 .NotFound.Ignore(); //could be bad data

}

public sealed class ProductCategoryMap : ClassMap
{

Table("ProductCategory");
Id(x => x.Code)
 .GeneratedBy.Assigned();

Map(x => x.Name).Not.Nullable();

Map(x => x.Type, "CatType").Not.Nullable();

}

The problem I have is that when I save a Product, the ProductCategory
is being updated.
I added the Cascade.None as an afterthought, but it didn't change
anything.

I see the Update statement being executed in the SQL Server Profiler,
so I'm not crazy. :)

Extra info
--
Before saving the Product, I retrieve the "ProductCategory" to make
sure it exists.
Then I assign the category, as found, to the Product.
(myProd.ProductCategory = myCat)
session.SaveOrUpdate(myProd)

How can I stop the update on the reference, this is extremely
undesirable?

Thanks,

Joe

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.



[fluent-nhib] Mapping CompositeId KeyReference on Interface

2011-08-03 Thread Maik
 I have a mapping problem concerning interface-references in an
composite-id: In the following class

class Foo {
public virtual DateTime Date {get;set;}
public virtual IInterface Reference {get;set;}
}

I want to have both properties be part of the CompositeID. With
Mapping Attributes this is done in the following way for a specific
implementation InterfaceImpl:

[CompositeId]
[KeyProperty(1, Column = "col1", Name = "Date", TypeType =
typeof(DateTime))]
[KeyManyToOne(1, ClassType = typeof(InterfaceImpl), Column =
"refcol2", Name = "Reference")]

Is there a way how this is done in fluent?

Thanks in advance, MacX

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.