You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by bhorvat <ho...@gmail.com> on 2011/12/16 23:39:58 UTC

Choosing hibernate configuration

This is my third question and the final one I promise :)

I know that I can add more hibernate configuration to the application like
this

  public void
contributeHibernateSessionSource(OrderedConfiguration<HibernateConfigurer>
conf) {
        conf.add("Default", new HibernateConfigurer() {

            public void configure(org.hibernate.cfg.Configuration
configuration) {
                configuration.configure("hibernate.xml");
            }
        });
    }

but this sometimes throw an error 'hibernate.dialect' must be set when no
Connection available
from what I read at the internet it is because the tapestry is trying to use
its default file hibernate.cfg.xml
I have also set 
        configuration.add("tapestry.hibernate.default-configuration",
"false");
but it is not working. I still get this error on some occasions

Since I can add more configuration to the OrderdConfiguration how can I tell
tapestry which one to take?

Thank you for assistance.
Cheers

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Choosing-hibernate-configuration-tp5081667p5081667.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Choosing hibernate configuration

Posted by Taha Hafeez Siddiqi <ta...@gmail.com>.
I think the problem is the naming. "Default" already exists so you should name it something else, otherwise it will use the one loaded first and so sometimes you will see it working correctly(as your configuration is being used) and sometimes it wont (when it uses the DefaultConfigurer from HibernateCoreModule and as DEFAULT_CONFIGURATION is set to false, it will not load hibernate.xml and so no dialect).

So the solution is to name it something else. Then it will load both and as DEFAULT_CONFIGURATION=false, your configuration will be used.

If you have multiple configurations(with different names/ids) all will be used in the order specified

regards
Taha

On Dec 17, 2011, at 8:02 AM, bhorvat wrote:

> Hm...That is pretty much what I thought. However it is acting a bit
> differently. 
> 
> I did set the property to full. But the system logged (whens starting up)
> was showing that the duplicate config file "Default" exists and that it will
> be ignored. Also for some reason on some occasions it would go fine and on
> others it would throw that exception 
> 
> Eventually I have changed the name from Default to HibernateConfig and it
> stop throwing errors. So probably even though I have set it to false the
> system was still complaining for using the same name.
> 
> One question if I add more configurations this way. Which one will be used?
> The last one?
> 
> Thanks for help
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Choosing-hibernate-configuration-tp5081667p5081908.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Choosing hibernate configuration

Posted by bhorvat <ho...@gmail.com>.
Hm...That is pretty much what I thought. However it is acting a bit
differently. 

I did set the property to full. But the system logged (whens starting up)
was showing that the duplicate config file "Default" exists and that it will
be ignored. Also for some reason on some occasions it would go fine and on
others it would throw that exception 

Eventually I have changed the name from Default to HibernateConfig and it
stop throwing errors. So probably even though I have set it to false the
system was still complaining for using the same name.

One question if I add more configurations this way. Which one will be used?
The last one?

Thanks for help

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Choosing-hibernate-configuration-tp5081667p5081908.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Choosing hibernate configuration

Posted by Taha Hafeez Siddiqi <ta...@gmail.com>.
If you set HibernateConstants.DEFAULT_CONFIGURATION to true(which it is by default), then org.hibernate.cfg.Configuration#configure() is called, which tries to look for "hibernate.xml" in the classpath. If it is not able to find the file, this exception is thrown.

If you set this Symbol to false, you have to call the configure() yourself and still in that case, if the file is not found the same error will be thrown. 

In short this exception is thrown 1) it can't find your hibernate.xml 2) you have actually not configured your 'hibernate-dialect' :)

Also, if you add multiple HibernateConfigurers, each one of them will be called to configure the same SessionFactory (in the order specified)

regards
Taha

On Dec 17, 2011, at 4:09 AM, bhorvat wrote:

> This is my third question and the final one I promise :)
> 
> I know that I can add more hibernate configuration to the application like
> this
> 
>  public void
> contributeHibernateSessionSource(OrderedConfiguration<HibernateConfigurer>
> conf) {
>        conf.add("Default", new HibernateConfigurer() {
> 
>            public void configure(org.hibernate.cfg.Configuration
> configuration) {
>                configuration.configure("hibernate.xml");
>            }
>        });
>    }
> 
> but this sometimes throw an error 'hibernate.dialect' must be set when no
> Connection available
> from what I read at the internet it is because the tapestry is trying to use
> its default file hibernate.cfg.xml
> I have also set 
>        configuration.add("tapestry.hibernate.default-configuration",
> "false");
> but it is not working. I still get this error on some occasions
> 
> Since I can add more configuration to the OrderdConfiguration how can I tell
> tapestry which one to take?
> 
> Thank you for assistance.
> Cheers
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Choosing-hibernate-configuration-tp5081667p5081667.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org