why does hibernate not force you to mark fields as virtual, but nhibernate does?
Is this a result of the differences between the VM and CLR?
why does hibernate not force you to mark fields as virtual, but nhibernate does?
Is this a result of the differences between the VM and CLR?
In Java all methods are by default virtual. In .NET you need to explicitly mark a method as virtual.
Because the default behaviour in Java is for methods to be overridable unless the final
keyword is specified, whereas in .NET it is for methods to be non-overridable unless the virtual
keyword is specified.
This isn't a difference between runtimes - it's a difference between languages.
In C#, methods aren't virtual by default. In Java, they are.
Note that neither platform allows fields to be virtual, as described in your question.
Hibernate and NHibernate both require virtual methods - which means making them explicitly virtual in C#.
(Note that in Java the terminology "virtual method" isn't actually defined in the language specification; here I'm using it to mean "non-final": a method which can be overridden.)