NHibernate.MappingException'Could not compile the mapping document: OrmEx.Customer.hbm.xml - nhibernate

I have a problem with Nhibernate mapping. Can you help me?
and that is my Customer.hbm.xml enter code here:
And soon as that is App Config
I use to sqlserver 2012 and NHibernate 5.0.0

Your mapping file has different namespace than your class, I suppose QuickStart assembly does not exists:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="OrmEx"
namespace="OrmEx">

Related

Fluently map assemblies/entities at run time

Simple question for I bet a not so simple answer.
Think of a project like Wordpress. The base of Wordpress is great and the developers built it to be extended with widgets or plugins etc.
Now think NHibernate, specifically with Fluent Mappings.
Put them together and you have a great and stable "base" system BUT how do you load mappings presented from external assemblies? I realize that the system would have to load the Assemblies on the fly using reflection but how do you configure nHibernate, Fluently, at first run to realize that there are extra entities to be loaded from those assemblies? How do you reference them?
I know you can;t add Mappings at run-time after the configurations is made, well you have to recreate the SessionFactory. This is why I want to load all required entities at runtime.
I also know that this can be somewhat accomplished with Dependancy Injection but I do not wish to go that route nor want the extreme baggage that comes with it.
If the plain old nHiberante config file can be modified and then referenced at runtime to reflect new Entities I can only assume there has to be a way to do it Fluently.
Also, based on answers: do you make the configuration from the base project or a DATA ACCESS assembly?
Thanks for your help.
You can pass an NHibernate Configuration object to Fluently.Configure(). That way you can update the configuration. You need to re-create the session factory when you do that, like you said.
You can scan the assemblies in the bin folder for assemblies that contain fluent mapping classes (Assembly.Load, then check
Assembly.GetExportedTypes()
.Any(x => x.IsClass
&& !x.IsAbstract
&& typeof(IMappingProvider).IsAssignabledFrom(type))
or similar) and add the assembly. When all assemblies are scanned, (re-)create the session factory.
I'm doing something similar in an extensible application framework I have written (although I've moved to from Fluent NHibernate to NHibernate mapping by code, but the principles are similar).

shorten type names in struts config

i have this really big struts-based web app that i have to maintain, and the package names follow this convention (more or less):
[app-name].[module].[module-variant].[layer].[activity].[activity-variant]
the jsp files are arranged in a similar fashion:
Web-Content/jsp/[app-name]/[module]/[module-variant]/[activity]/[activity-variant]
so when i have to add another action mapping to the struts-config.xml i have to write
again this :
[app-name].[module].[module-variant].[layer]
and this for the foward:
/jsp/[app-name]/[module]/[module-variant]/
with a couple of action mappings, the struts-config.xml file gets really noisy, and its hard to understand the action fowards at a glance.
So, is there any way to specify globaly a package name so i dont have to write the fully qualified name for each action class in the struts-config.xml ?,
for example in a hibernate mapping you can specify "package" and "schema" and refer to the table/classes with their short name
btw im using struts 1.3
As far as I know there is no way to do that; Struts expects fully qualified class name for the ActionForms, Actions etc.
What you could do is write a "your's special" struts-config.xml file with global names and stuff, then pass it through a tool at build time to re-generate the actual struts-config.xml that Struts is expecting.
You could also have the struts-config.xml file generated entirely at build time by placing some "annotations" (not Java 5 annotations :D) in the Action classes using XDoclet.
Or you could resort to a nice formatting of the xml and just get used to it.

i need NHibernate.ByteCode.Castle source code

I need to get into FluentNhibernate and NHibernate code so i rebuild the solutions
and used the new assemblies, but the problem is that there is an assembly called
NHibernate.ByteCode.Castle.Dll which refuses to load the my own version of Nhibernate
and keep telling me that the Public Token doesn't match, so where can i get the source code
for this assembly, so i can reference my NHibernate assembly and rebuild it???
or may be the question is : is it open source ???
:$
how stupid I am !!!!
it comes with Nhibernate source code,but what made me confused is when I opened the Nhibernate Solution, the Nhibernate.ByteCode.Castle project wasn't there! !!!
but there is another solution file called NHibernate.Everything.sln, i opened it, and voila !!!
there it is in the solution.

How to quote Fieldnames in Fluent NHibernate 1.1

After upgrading from Fluent NHibernate 1.0 RTM to 1.1 I got some strange errors when creating the database. After some investigation I discovered that FNH 1.0 quoted all field names in the generated mapping files like 'user', but FNH 1.1 did not. This results in errors for the generated sql script when I use restriced keywords for properties.
Is it somehow possible to reactivate this feature of FNH 1.0 or enable quoting otherwise?
Are you talking about the code that is generated and sent to the sql server or the psedo mappings files it generates?

Generating nHibernate cfg file from Configuration instance

Is there any way for me to generate an nHibernate configuration file from a Configuration instance (that has been already configured by some external code?). I'm looking for an easy way to mimic this external code with a static XML file?
(I guess similar to the "ExportTo" method that Fluent nHibernate has for fluent mappings - but acting on the resulting Configuration object instead).
Thank you!
No, there is no way to do that easily.
What can be done (and is common) is binary serialization of the configuration. Check http://github.com/ayende/Effectus/blob/master/Effectus/Infrastructure/BootStrapper.cs