In one application, I associate user accounts with computers based on
usage of the computer. I have to both access the computers from the
accounts and vice versa in many places in my code. Therefore I took
the way to make it bidirectional using Add/Remove-Methods to assure
that the association is
Then why do have the BlogId property in there? Simply discard it.
-Markus
2009/1/12 Mark Jensen don...@gmail.com:
haven't tested it yet, but is it really required to make it
bidirectional for this to work ?
because I only need it to go one way :/
On Jan 10, 2:41 pm, Markus Zywitza
Yep :) but if i remove the property from the object I get the above
error
On Jan 12, 2:04 pm, Colin Ramsay colinram...@gmail.com wrote:
You need the column in the DB but you don't need the property on the
post object.
On Mon, Jan 12, 2009 at 12:44 PM, Mark Jensen don...@gmail.com wrote:
Just checking, I mean you should still have:
[BelongsTo(BlogId)]
public Blog Blog {get; set;}
But remove:
[Property(BlogId, NotNull = true)]
public Guid BlogId { get; set; }
On Mon, Jan 12, 2009 at 1:17 PM, Mark Jensen don...@gmail.com wrote:
Yep :) but if i remove the property from the
a :)
im sure how bidirectional works in NH, but from the description you
give me, it sounds like that unidirectional adds a little bit more
work when is persists objects ?
Even though i dont really need it to be bidirectional, would be better
performance wise to go with bidirectional
woops.. i mean... im NOT sure how NH works...
On Jan 12, 2:34 pm, Markus Zywitza markus.zywi...@gmail.com wrote:
Remove the not null-constraint from the database column.
This is needed as NH works this way:
1) You save the parent
2) Parent cascades to newly created child
3) Child is saved
It would be /slightly/ better performance wise but you should avoid
bidirectional associations where possible. Bidirectional association is
rarely necessary and usually highlights a flaw in your modelling. The
performance hit isn't exactly huge anyway and unless you've measured you're
making a
So when would you consider to use bidirectional association ?
When you need to access the objects via both directions.
-Markus
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Castle Project Users group.
To post to
haha, yeah :P
but do you have an example when this could be relevant :)
On Jan 12, 3:59 pm, Markus Zywitza markus.zywi...@gmail.com wrote:
So when would you consider to use bidirectional association ?
When you need to access the objects via both directions.
-Markus
I have switched over to Guids (GuidComb) instead
Now the foreignkey in Post is just guid.empty :/ when I create a new
Blog and add a Post to it.
On Jan 9, 1:19 pm, Markus Zywitza markus.zywi...@gmail.com wrote:
Here is my setup/teardown:
[SetUp]
public void Setup()
schema generation:
http://www.castleproject.org/activerecord/documentation/trunk/usersguide/schemagen.html
When you create a new Post, it's ID is Guid.Empty. That's just fine,
as this is the unsaved value. When the post is saved and flushed, it
is assigned an Guid generated by NH.
-Markus
Can you post the Post type please?
2009/1/9 Mark Jensen don...@gmail.com:
Thanks, I read that... but I dont understand the Paramter in the
CreateSchema()
anyway...it is not the ID on Post that is the problem.. it is the
BlogID on Post that is empty after I persist Blog with Blog.Save().
Sure thing :)
I have removed a few things but the essential things should be there
public abstract class BaseEntityT : ActiveRecordValidationBaseT
where T : class
{
private readonly DateTime created;
private DateTime modified;
public BaseEntity()
{
created =
Yes, I overlooked that you used
Cascade = ManyRelationCascadeEnum.SaveUpdate
That must be
Cascade = ManyRelationCascadeEnum.AllDeleteOrphan
to automatically delete posts.
-Markus
2009/1/8 Mark Jensen don...@gmail.com:
Hi Markus
the Inverse = true, doesn't seem to do anything, the changes
Do you use MSSQL Identity for your PKs?
-Markus
2009/1/8 Mark Jensen don...@gmail.com:
BTW. when I Add a new Post the BlogID is zero when I persist this way
Blog.Save();
On Jan 8, 3:18 pm, Markus Zywitza markus.zywi...@gmail.com wrote:
2009/1/8 Mark Jensen don...@gmail.com:
Atm, yes
I haven't really dicided if I shoud go with Identity og Guids I
have choosen Identity so fare, because i believe it to be faster..
On Jan 8, 3:46 pm, Markus Zywitza markus.zywi...@gmail.com wrote:
Do you use MSSQL Identity for your PKs?
-Markus
2009/1/8 Mark Jensen
When I switch my primarykeys on Blog and Post to HiLo I get the
following error
System.Data.SqlClient.SqlException: Invalid object name
'hibernate_unique_key'.
On Jan 8, 3:51 pm, Markus Zywitza markus.zywi...@gmail.com wrote:
GuidComb is nearly as fast as Identity. With AR/NH its even faster
You have to recreate the schema. It creates a table to store the next hi to use.
2009/1/8 Mark Jensen don...@gmail.com:
When I switch my primarykeys on Blog and Post to HiLo I get the
following error
System.Data.SqlClient.SqlException: Invalid object name
'hibernate_unique_key'.
On Jan
recreate? how
Atm I running the thing in a unittest where I do the following
XmlConfigurationSource source = new XmlConfigurationSource(../../
AppConfig.xml);
Assembly asm = Assembly.Load(myDomain);
ActiveRecordStarter.Initialize(asm, source);
On Jan 8, 4:10 pm, Markus Zywitza
ActiveRecordStarter.CreateSchema();
ActiveRecordStarter.DropSchema();
ActiveRecordStarter.UpdateSchema();
2009/1/8 Mark Jensen don...@gmail.com:
recreate? how
Atm I running the thing in a unittest where I do the following
XmlConfigurationSource source = new XmlConfigurationSource(../../
20 matches
Mail list logo