No Persister found for type xxx

22 views
Skip to first unread message

Regis Dubois

unread,
Jul 5, 2011, 12:13:05 PM7/5/11
to castle-pro...@googlegroups.com
Hi,

I have been using ActiveRecord for quite a while, so far without much
issues.

Today however I came accross a problem which baffles me.

I have attached some code as it better describes the issue.

Basically I compile a class and register it dynamically within
ActiveRecord (using ActiveRecordStarter.RegisterAssemblies(typeAssembly))
and then create an object of this type using reflection.

Calling Save() on the object works fine and it is perfectly commited into
the DB.

HOWEVER, if I attempt to first perform a search on another ActiveRecord
Type then I get a "no persister found" exception when trying to save.

I know... that makes no sense...

I have attached some code to this email, can somebody kindly have a look
at the problem?

The code comes with 2 unit tests, one to create the type, the second one
to persist the object.

To reproduce the problem, just uncomment the line:

//TypeRelationship.FindByOwnerId(typeId);

Thanks,

Regis

ActiveRecordDebug.zip

Nick Kilian

unread,
Jul 5, 2011, 12:31:10 PM7/5/11
to Castle Project Users
Reg,

haven't checked your code yet to see how you're compiling the code,
but could this help you?

http://groups.google.com/group/castle-project-users/browse_thread/thread/a925c532b11a212c/
>  ActiveRecordDebug.zip
> 2550KViewDownload

Nick Kilian

unread,
Jul 5, 2011, 12:45:16 PM7/5/11
to Castle Project Users
Oh right, it's you again, so another problem then? ;-D

On Jul 5, 6:31 pm, Nick Kilian <nicholaskil...@googlemail.com> wrote:
> Reg,
>
> haven't checked your code yet to see how you're compiling the code,
> but could this help you?
>
> http://groups.google.com/group/castle-project-users/browse_thread/thr...

Regis Dubois

unread,
Jul 5, 2011, 1:52:16 PM7/5/11
to Castle Project Users
Hey Nick ;)

I have a talent for breaking things...

If you have a minute please check the code and advise. (I could to the
find using an sql statement as a workaround but I'd like to know if
this is a genuine AC bug or just me doing something wrong)

Thanks,

Regis

Regis Dubois

unread,
Jul 5, 2011, 1:58:51 PM7/5/11
to Castle Project Users
Just to try and clarify.

compiling does not seem to be the issue.

saving the object works fine, however trying to perform a find on
another AC type before saving (1 line of code...), causes the Save()
to throw an exception.

Nicholas Kilian

unread,
Jul 6, 2011, 1:58:42 AM7/6/11
to castle-pro...@googlegroups.com
If you move

TypeInformation ti = TypeInformation.FindByName("iTradeType1");

So it is after your call to

RegisterAssemblyInActiveRecord(typeAssembly);

Then it works fine. So if it's possible for you to register your dynamic
types before the first database call to AR then I would suggest taking that
route.

--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to
castle-project-u...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.

Regis Dubois

unread,
Jul 6, 2011, 3:35:22 AM7/6/11
to castle-pro...@googlegroups.com
Hi Nicholas,

Not sure I can since the call is embedded within a recursive call method.

Should this not be logged as a bug?

> To post to this group, send email to castle-project-
> us...@googlegroups.com.


> To unsubscribe from this group, send email to
> castle-project-u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/castle-project-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Castle Project Users" group.

> To post to this group, send email to castle-project-
> us...@googlegroups.com.


> To unsubscribe from this group, send email to castle-project-

> users+un...@googlegroups.com.

Regis Dubois

unread,
Jul 6, 2011, 5:27:28 AM7/6/11
to Castle Project Users
Actually this is not a suitable solution at all.

new Type can be registed in the system at any time. Call to the db can
be made before and after any dynamic type is registered.

I consider this a basic functionnality of AR

On Jul 6, 6:58 am, Nicholas Kilian <nicholaskil...@googlemail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages