usertype

NHibernate CompositeUserType: How to specify Sql Types?

Using NH 2.0, I have a custom type. It is composed of four properties, so I implemented ICompositeUserType. I want to specify length and precision for the string and decimal properties within the user type, to avoid specifying it with every usage in the mapping files. But there is only a PropertyTypes property to implement, which retu...

Unit testing NHibernate UserTypes

Does anyone have a good approach towards unit testing their UserTypes? By way of example, I have an object in my model called DateRange, which has a DatePoint start and DatePoint end. In addition to making range type operations available for two DateTimes, these objects let me adjust the precision for the task at hand (i.e., Day, Hour, ...

NHibernate mapping: UserTypes with many-to-one

New to NHibernate and learning it as we are modifying an existing solution to use this ORM. Ideally, the storage structure and object classes need to stay the same, so Ive come across one or two mapping problems. One class 'Money' has a value and currency. The value is a double and the currency is a foreign key to a list table of curren...

Map database column1, column2, columnN to a collection of elements

In legacy database tables we have numbered columns like C1, C2, C3, C100 or M1, M2, M3, M100. This columns represent BLOB data. It is not possible to change anything it this database. By using JPA Embeddable we map all of the columns to single fields. And then during embedding we override names by using 100 override annotations. Recen...

Why are user types not highlighted in Visual C++?

I would like to have Visual Studio highlight the names of my own classes in the text editor. I have selected a color under User Types in Options > Fonts & Colors -- but strangely, this only works for Visual C# but not Visual C++. Any ideas what's going on? EDIT: I received some great tips regarding 3rd party tools in response to my pr...

Hibernate custom UserType isn't working

I've created a UserType (see below) to handle a situation in our mySQL database where we've been saving null dates as 0000-00-00 00:00:00. When I try and persist my entity with a null for dispDT (see below) it generates this exception: "javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property refer...

NHibernate property mapping: columns and formula

When i map columns from the inspected table, i do this: <property name="InstanceName" type="MyNameUserType, MyApp.MyNamespace"> <column name="Name"/> <column name="Name2"/> </property> How can I make property mapping initialize a UserType with data retrieved by the formula's sql query? <property name="InstanceName" type="MyName...

Error mapping UserType from to property with NHibernate

I needed a way to trim strings within my persistent class because my legacy database is using char fields. I downloaded the nHhaddIns dll to use its TrimString class which is derived from IUserType. Using their example I created a property in my mapping class as shown at the bottom. uNHAddIns is added as a project within my solution. H...

Query on hibernate entity with user-type field

Hey, working with JPA above hibernate impl. I map my enums by using user-type follow the good practice to store a persistence key to the enum and not the ordinal (which can be changed). Now, i have a problem to query on the enum field. it seems that hibernate dont execute the user type convert on the name-query. Any idea? ...

How to define UserType' s name globally in Hibernate?

It's possible to use @TypeDefs annotation to define short type name for a UserType. But how to define it for entire application? ...

NHibernate UserType value on object

Hi. I'm using a UserType to maintain a column (Created) in my db. When saving to db i simply check if the property in question equals DateTime.MinValue, and if so updates it to DateTime.Now (overriding NullSafeSet). This update however, is not immediately reflected by nhibernate, and if i load the object again without evicting it, th...

How to map IDictionary<string, object> in Fluent NHibernate?

I am looking to persist user preferences into a collection of name value pairs, where the value may be an int, bool, or string. There are a few ways to skin this cat, but the most convenient method I can think of is something like this: public class User { public virtual IDictionary<string, object> Preferences { get; set; } } wit...

Hibernate bit array to entity mapping

I am trying to map a normalized Java model to a legacy database schema using Hibernate 3.5. One particular table encodes a foreign keys in a one-to-many relationship as a bit array column. Consider tables person and club that describes people's affiliations to clubs: person: .----.------. club: .----.---------.----------------------...

Hibernate: Programmatically binding UserType's on Components

I have several different UserType's (org.hibernate.usertype.UserType) in the system. For this question I will focus on the fact that we use Joda time DateTime and its UserType, PersistentDateTime. I have successfully bound the UserType programmatically to PersistentClass's by: public void customize(Ejb3Configuration config) { Iterato...

Allowing different user types registrations in Drupal 6?

I have two types of users on my site: Normal user Supplier How do I set up Drupal so that you can choose which type of user you want to be before signing up, and then also (and this is the tricky part) give different profile fields to the different user types? ...

Assign values to keywords in usertype.dat in visual studio?

I found that if you create a file called "usertype.dat" in visual studio's IDE dir, that you can specify keywords that will appear in blue like "new" or "int". Is there a way to assign values to these? I don't want to have to use "#define [keyword] [value]" in every single file that I use.. Specifically, I would like to have a "null = ...

Grails: domain class mapping (collection of hibernate user types)

Hello, I am wondering if is possible to implement following domain model. Let's have a domain class which contains set of intervals (joda time). I can use org.joda.time.contrib.hibernate.PersistentInterval hibernate user type for mapping of Interval to database table (by similar way as in http://www.grails.org/JodaTime+Plugin). However...