castle-activerecord

VB.NET, Castle ActiveRecord and MySQL: Duplicate entry in a unique field

Hi. When user inserts a duplicate entry in a unique field, Castle ActiveRecord throws the following exception: Castle.ActiveRecord.Framework.ActiveRecordException was unhandled Message="Could not perform Save for SerieNotaFiscal" Source="Castle.ActiveRecord" StackTrace: at Castle.ActiveRecord.ActiveRecordBase.InternalSave(O...

How can I define an Order parameter through a belongsTo table in Castle ActiveRecord

Hi guys take a look in the following entity: Produto = Products (in english) [ActiveRecord("produtos", Lazy=true)] public partial class Produto : ActiveRecordBase<Produto>, IObjetoEntidade<Produto> { [PrimaryKey(PrimaryKeyType.Native, "prod_id")] public virtual int Id { get; set; } [StringLengthValidator(0, 100)] [Prop...

Avoid first level cache for an entity in NHibernate?

I have an entity which is updated externally (using triggers, stored procedures). This means the entity can change without my knowledge in the same session, and it is required for me that I always perform a database hit, and never use the entity from the first level cache. Is this possible using NHibernate (or actually, Castle ActiveRec...

Mapping production database

I just completed mapping 100~ tables from our production Oracle database. Along the way I noticed that many relationships were not modelling. Mostly foreign keys. Should I modify my mappings to include the appropriate relationships? Or should I keep the mapping as is to reflect the database 100%? I'm more inclined the map the appropria...

How does Castle.ActiveRecord override virtual properties?

In active record to write a model you write: [ActiveRecord("TableName")] public class Model { [Property("SomeField")] public virtual string SomeField { get; set; }; [Property("SomeLazyField"), Lazy= true] public virtual string SomeLazyField { get; set; }; } If the field is lazy it must fetch it on the first access, so ...

One to one relationship mapping with composite key

Hi everybody, I have a database like this: My question is "How to mapping this database using castle active record?" I've tried this code: Campaign: [ActiveRecord("[Campaign]")] public class Campaign : ActiveRecordBase<Campaign> { private long m_ID; [PrimaryKey(Column = "`ID`")] public long ID {...

Why do I need to set an alias to my projection if it's optional?

I'm reading the documentation about DetachedCriteria. The documentation clearly shows that setting an alias for your projection is optional. However, whenever I omit the alias my model properties contain no data. Here are my two test models. [ActiveRecord("INCIDENT")] public class Incident : ActiveRecordBase<Incident> { [PrimaryKey(...

Castle ActiveRecord Integration w/ multiple databases

Hi everyone... There is a way to use Castle ActiveRecord Integration (Castle.Facilities.ActiveRecordIntegration.dll) with multiple databases? I'm already aware of using NHibernate with multiple database and ActiveRecord as well. But applied to integration facility i don't found anything. Any suggestions? Tks!! ...

accessing a table where the column name is a reserved keyword

I am setting up Castle Active Record to access a legacy database on an Microsoft SQL Server. The table in question has a column named function. When I attampt to load a record it gives me this error: Incorrect syntax near the keyword 'function' This error comes about because the SQL query nhibernate generates attempts to access the c...

Using Castle ActiveRecord to query from multiple tables

So I've been using Castle ActiveRecord for my latest project and for the most part I like it a lot. Now I'm trying to figure out how to execute a simple join query with AR and I'm not seeing it. So I have an Article table and an article could have many tags associated to it. This is the attribute in the Article class: [HasAndBelongsToM...

Castle ActiveRecord and AfterLoad event

Castle ActiveRecord has BeforeLoad event but I need AfterLoad event too. I know it's possible to use NHibernate's PostLoad event. But how can I do this? ...

ActiveRecord/NHibernate DateTime problem

I'm using ActiveRecord/NHibernate for ORM mapping in my project with PostgreSQL 8.4. I have following issue For class mapping [ActiveRecord(Schema = "public", Table = "test_bean")] public class TestBean { [PrimaryKey(SequenceName = "test_bean_id_seq", Generator = PrimaryKeyType.Sequence)] public int ID { get; set; } [Castle.A...

Invalid primary key datatype [int]

I am using Afo Castle AR Code Generator v1.0.0.4 at first I was receiving errors for using tinyint as a primary key so I changed those to int but the only error I have left and can't seem to get rid of is Invalid primary key datatype [int] for table dbo.Level_Code. Only int identity and uniqueidentifier primary keys are suppor...

How to map HasMany using non Primary Key column?

Hi I use Castle.ActiveRecord's HasMany mapping. I have something like: [HasMany (typeof (childtype), ColumnKey = "this_relation_column", Table = "childtype_table")] I would like to use a different column on childtype_table to relate with this_relation_column. Actually, this_relation_column is of type text (string), and the PK of child...

Is there any considerations when using log4net in an application that uses NHibernate or Castle ActiveRecord?

Hi all, I used log4net in a sample application based on tutorial here. It works very well. But when I use same code and configuration in my main application, nothing works. My application is based on Castle ActiveRecord that itself is based on NHibernate. Both Castle ActiveRecord and NHibernate uses log4net internally. I'm suspicious ab...

Many-To-Many relation through non-primary key for legacy system

I have a legacy system I'm working on and there is a particular relationship I'm having trouble with. The issue is that I need to relate Patient to HL7EPICareMeds... the relationship above isn't working, of course. From the table perspective, here is what I have Patient: PatientId : int, PK ClinicPatientId : varchar --- not unique ...

log4net: deny other components except than a specific one from logging

Assume you are using some libraries like NHibernate or Castle ActiveRecord that use log4net internally. Your application uses log4net too. It's possible to configure all applications to save logs into file or any other output. But the problem is by enabling log4net for my own application, other programs save their log into the log file a...

Datetime string in HQL

hi, I am using Castle ActiveRecord for my application. My problem is how to use a datetime string in HQL like this (without using parameters): "from Contact c where c.DayOfBirth = '5/3/1988'" ...

Add SQL query options to NHibernate query

I'm working with some code that generates ICriteria queries for NHibernate. They get executed using ActiveRecord and ActiveRecordMediator.FindAll() For certain queries, I need to optimise them by adding on an OPTION (HASH JOIN) hint at the end of the SELECT statement. Is there a quick way I can do this? I don't want to rewrite the qu...

A different object with same identifier was already associated with the session error

Scenario: I have a customer object with lazy loading enabled. I use that throughout the program to call a list of customer for a listbox. It has relationships to the Division_Customer_Rel, Division_Email_Rel and Email_Address objects. All off the relationships have Lazy = true, Cascade = ManyRelationCascadeEnum.AllDeleteOrphan, Inverse =...