-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Slow startup w/.Net NHib app
PostPosted: Fri Jun 01, 2007 2:12 pm 
Newbie

Joined: Sat Sep 02, 2006 7:27 am
Posts: 5
Location: Cleveland, OH
We are using NHibernate 1.0.3 to develop an ASP.NET (.NET 2.0) application. We have about 70 classes in the model and are using AndroMDA to generate the hbm.xml files and C# source. The issue is that it takes apx 30-40 seconds each time we start the server to process the persistent class mappings. If I'm reading the debug logs correctly, it appears that it is creating an assembly for each hbm.xml file. Is there something I've done wrong or a way to speed up the startup process? Going to 1.2 is a future option for us but we can't make the switch for now.

thanks!

Here's typical hbm.xml file in our project

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!--
     Name: PlugIn.hbm.xml
     License text for HBM.XML files - Change in mda/conf/mappings/MergeMappings.xml

     Attention: Generated code! Do not modify by hand!
     Generated by: nhibernate.hbm.xml.vsl in andromda-nhibernate-cartridge.
  -->
<hibernate-mapping
    xmlns="urn:nhibernate-mapping-2.0"
    default-cascade="none">

    <class
        name="Safeguard.SPI2.Domain.Core.PlugInImpl, SPI2ModelCore"
        table="PLUGIN"
        dynamic-insert="false"
        dynamic-update="false"
        lazy="true">

        <id name="ObjectID" type="Int64" unsaved-value="0">
            <column name="OBJECTID" sql-type="NUMBER(19)"/>
            <generator class="sequence">
                <param name="sequence">PLUGIN_SEQ</param>
            </generator>
        </id>

        <property name="ExtendedAttrs" type="String">
            <column name="EXTENDEDATTRS" not-null="false" unique="false" sql-type="VARCHAR2(4000)"/>
        </property>

        <set name="Annotations" order-by="EXTENDABLE_FK" lazy="true" outer-join="auto" inverse="false">
            <key foreign-key="ANNOTATIONEXTENDABLE_FKC">
                <column name="EXTENDABLE_FK" sql-type="NUMBER(19)"/>
            </key>
            <one-to-many class="Safeguard.SPI2.Domain.Core.AnnotationImpl, SPI2ModelCore"/>
        </set>

        <set name="Categorizations" order-by="EXTENDABLE_FK" lazy="true" outer-join="auto" inverse="false">
            <key foreign-key="CATEGORIZATIONEXTENDABLE_FKC">
                <column name="EXTENDABLE_FK" sql-type="NUMBER(19)"/>
            </key>
            <one-to-many class="Safeguard.SPI2.Domain.Core.CategorizationImpl, SPI2ModelCore"/>
        </set>

        <set name="PlugIns" order-by="EXTENDABLE_FK" lazy="true" outer-join="auto" inverse="false">
            <key foreign-key="PLUGINEXTENDABLE_FKC">
                <column name="EXTENDABLE_FK" sql-type="NUMBER(19)"/>
            </key>
            <one-to-many class="Safeguard.SPI2.Domain.Core.PlugInImpl, SPI2ModelCore"/>
        </set>

        <property name="ExtensionId" type="String">
            <column name="EXTENSIONID" not-null="false" unique="false" sql-type="VARCHAR2(255)"/>
        </property>

        <property name="ExtensionPointId" type="String">
            <column name="EXTENSIONPOINTID" not-null="false" unique="false" sql-type="VARCHAR2(255)"/>
        </property>

        <property name="Version" type="String">
            <column name="VERSION" not-null="false" unique="false" sql-type="VARCHAR2(255)"/>
        </property>

        <property name="IsEnabled" type="Boolean">
            <column name="ISENABLED" not-null="false" unique="false" sql-type="NUMBER(1)"/>
        </property>


    </class>
    <!-- NHibernate.hbm.xml.vsl merge-point -->
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 01, 2007 4:40 pm 
Newbie

Joined: Fri Apr 01, 2005 5:20 pm
Posts: 14
Hey,

I had the same thing. There is a couple of threads about it in the forum. But to save you some search time,

Code:
[b]NHibernate.Cfg.Environment.UseReflectionOptimizer = false;[/b]
NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration();
config.Configure();
sessionFactory = config.BuildSessionFactory();


Put the bold line in before you do the config. I think this is a hit in the long run for when the program is in actual use, but it is not really noticeable and the startup time is very short.

You can probably put this in the properties as well, but I have had more success putting it in the code. Just starting with 1.2 and had to do it there as well.

_________________
Thanks,

John


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 01, 2007 4:55 pm 
Regular
Regular

Joined: Sun Jan 21, 2007 4:33 pm
Posts: 65
Quote:
f I'm reading the debug logs correctly, it appears that it is creating an assembly for each hbm.xml file. Is there something I've done wrong or a way to speed up the startup process?
Maybe I'm reading your comment wrong, but it sounds like you are saying it's creating an assembly for each hbm.xml file.

If you do mean 'assembly', then I assume you don't have the .hbm.xml and class libary files already stuck together into an assembly? If you did, then you'd just need to add that assembly to the configuration at bootup, and all of your mappings and classes would be in one place.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 02, 2007 7:07 am 
Newbie

Joined: Sat Sep 02, 2006 7:27 am
Posts: 5
Location: Cleveland, OH
Thanks John,
I did see a thread about this option but it also suggested that performance at runtime would suffer. Is this true? Have you experienced any degrading in performance?


Quote:
If you do mean 'assembly', then I assume you don't have the .hbm.xml and class libary files already stuck together into an assembly? If you did, then you'd just need to add that assembly to the configuration at bootup, and all of your mappings and classes would be in one place.


No, all the classes and hbm.xml files are in one assembly. What I'm referring to is that when you look at the debug log for IIS, it displays each assembly that it's loading to look for symbols. In that log, there are ALOT of generated assemblies that I'm assuming were created by the NHib start-up. I maybe wrong about that but it's definitely where the time is being spent.

thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.