Thursday, August 12, 2010

CDN for jQuery, AJAX and other API's

Just want to share that jQuery, Microsoft AJAX and other API's are hosted in CDN by both Microsoft and Google. You can check the following pages:

What is the benefit of using CDN?

A Content Delivery Network (CDN) improves the performance of your sites by caching and delivering contents like images, javascript and css.
  • It increases the parallelism available.
  • It increases the chance that there will be a cache-hit.
  • It ensures that the payload will be as small as possible.
  • It reduces the amount of bandwidth used by the server.
  • It ensures that the user will get a geographically close response.

Tuesday, August 10, 2010

DuplicateMappingException

I have been a programmer for two years already and I have decided to start a journal of the things I experience in my work that can help others like me.

I am currently in a project with more than 1 team doing an application and yesterday after the merge we were experiencing this exception. Upon further investigation we saw that we have an objects which have the same name but in 2 different namespace.


Mapping 1:
<hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2">
<class name="NHibernateDemo.VO.Customer, NHibernateDemo" table="VOCustomer">
<id name="Id" column="Id" unsaved-value="0">
<generator class="native" />
</id>
<property name="FirstName" column="FirstName" not-null="true"/>
<property name="LastName" column="LastName" not-null="true" />
<property name="Email" column="Email" not-null="true" />
</class>
</hibernate-mapping>
Mapping 2:

<hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2">
<class name="NHibernateDemo.AC.Customer, NHibernateDemo" table="ACCustomer">
<id name="Id" column="Id" unsaved-value="0">
<generator class="native" />
</id>
<property name="FirstName" column="FirstName" not-null="true"/>
<property name="LastName" column="LastName" not-null="true" />
<property name="Email" column="Email" not-null="true" />
</class>
</hibernate-mapping>
The solution was to add "auto-import= false" in the mapping file and use the fully qualified name in the two mapping files.
<hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2" auto-import="false">
But what does the auto-import attribute do? From the NHibernate Reference Documentation it says that it lets us use unqualified class names in the query language, by default. And it is set as true by default.