cancel
Showing results for 
Search instead for 
Did you mean: 

Is it alfresco sharing hibernate config?

jose_tristan
Champ on-the-rise
Champ on-the-rise

Hi,

we have an independent war in the same tomcat that deploy alfresco wars. This war also uses hibernate but connects with a different database. We are detecting that hibernate is using the same dialect set in Alfresco. 

Is Alfresco sharing the hibernate config?

Thanks.

1 ACCEPTED ANSWER

I found the issue. Alfresco is using Hibernate version 3.2.6 wich in class DialectFactory in method buildDialect is saving the "hibernate.dialect" as Java System property. In new versions, this method doesn't save the value in "hibernate.dialect.

 public static Dialect buildDialect(Properties props, String databaseName, int databaseMajorVersion) throws HibernateException {
    String dialectName = props.getProperty("hibernate.dialect");
    if (dialectName == null || dialectName.length() == 0)
      return determineDialect(databaseName, databaseMajorVersion); 
    System.setProperty("hibernate.dialect", dialectName);
    return buildDialect(dialectName);
  }

View answer in original post

3 REPLIES 3

afaust
Legendary Innovator
Legendary Innovator

Alfresco is barely using Hibernate - AFAIK the only Hibernate feature still used is the dialect detection and potentially some transaction handling. Alfresco is not actively "sharing" the Hibernate configuration. If you have provided the Alfresco config property "hibernate.dialect" via a Java -D system property, then of course that value will also be available to any other applications running on the same application server, and may influence their behaviour. This would be a configuration error, not an issue in Alfresco itself.

Thanks. Indeed I've seen "hibernate.dialect" is being saved as s java system property. However, I'm not able to find the responsible of that.

I found the issue. Alfresco is using Hibernate version 3.2.6 wich in class DialectFactory in method buildDialect is saving the "hibernate.dialect" as Java System property. In new versions, this method doesn't save the value in "hibernate.dialect.

 public static Dialect buildDialect(Properties props, String databaseName, int databaseMajorVersion) throws HibernateException {
    String dialectName = props.getProperty("hibernate.dialect");
    if (dialectName == null || dialectName.length() == 0)
      return determineDialect(databaseName, databaseMajorVersion); 
    System.setProperty("hibernate.dialect", dialectName);
    return buildDialect(dialectName);
  }