-->
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.  [ 14 posts ] 
Author Message
 Post subject: Where can I set global settings
PostPosted: Fri Jul 10, 2009 7:48 am 
Newbie

Joined: Tue Nov 11, 2008 5:55 am
Posts: 9
Location: Barneveld, Netherlands
Hi,


I am using Hibernate Tools to generate domain code and hbm files. I am using the Eclipse plugins for that.

I want to control the default-lazy attribute in the hibernate-mapping element. Looking at the template this seems to be controlled by something called global settings. Where can i set these global settings? I tried setting a property in the exporter in the Eclipse plugin, but that failed.


Best regards, René


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Tue Aug 04, 2009 8:30 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
You can't set up global settings anyhow.
But you can use custom template instead.
Create in folder myTemplates folder hbm and file hibernate-mapping.hbm in hbm folder.
Enter
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<!-- Generated ${date} by Hibernate Tools ${version} -->
<hibernate-mapping default-lazy="false">
<#include "persistentclass.hbm.ftl"/>
</hibernate-mapping>

as file content.
When you run export in eclipse set up custom template folder to myTemplates folder.


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Tue Aug 04, 2009 8:53 am 
Newbie

Joined: Tue Nov 11, 2008 5:55 am
Posts: 9
Location: Barneveld, Netherlands
Hi Dmitry,

Thank you very much for your reply. I have used custom templates already to customize the output of Hibernate Tools. However, it would have been nice if the output could be influenced by setting some parameters somewhere. I wanted to be able to switch between lazy loading enabled and disabled in an easy way. Too bad that i cannot.

I'll change the template whenever i need to then. Thanks again.


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Tue Aug 04, 2009 8:59 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
Quote:
I wanted to be able to switch between lazy loading enabled and disabled in an easy way.

Nothing could be easier.
Just create 2 launch configurations. One with custom template, other without it.


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Tue Aug 04, 2009 9:02 am 
Newbie

Joined: Tue Nov 11, 2008 5:55 am
Posts: 9
Location: Barneveld, Netherlands
Hi Dmitry,

Never thought about that! I often tend to overlook the obvious.

Thanks.


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Tue Aug 04, 2009 10:08 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
You are welcome!


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Fri Aug 07, 2009 5:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you can actually control global settings. look at HibernateMappingExporter which takes in a HibernateMappingGlobalExporter - requires subclassing to control but it is there if needed :)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Fri Aug 07, 2009 5:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
note customizing the template is by far the simplest approach...but if you want to you can do it programmaticallly too.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Mon Aug 10, 2009 1:54 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
Max, the feature you a talking about is accessible in ant-task, but not directly in IDE, isn't it?


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Mon Aug 10, 2009 3:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
You can setup custom exporters in both Ant and the IDE.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Mon Aug 10, 2009 3:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
custom exporters *and* properties to be precise. So no, this is accessible from both "ui"'s.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Mon Aug 10, 2009 4:22 am 
Newbie

Joined: Tue Nov 11, 2008 5:55 am
Posts: 9
Location: Barneveld, Netherlands
Hi Max,


When you talk about the custom exporter in the IDE you mean the Generic Exporter, i suppose? The Hibernate Tools Reference Guide refers to ANT solutions only, but i imagine that I should add the hbmtemplate attributes as properties to the Generic Exporter in the Eclipse Exporters dialog? I found that most of the properties refer to attributes that are documented in the Hibernate Tools Reference Guide, but I am missing the property exporterclass which seems crucial to me if i want to create my own exporter. Is it simply a matter of adding this property as a "custom" property?


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Mon Aug 10, 2009 4:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes. there is a 1-to-1 correspondance here. if not - that is a bug ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Where can I set global settings
PostPosted: Mon Aug 10, 2009 4:35 am 
Newbie

Joined: Tue Nov 11, 2008 5:55 am
Posts: 9
Location: Barneveld, Netherlands
I will try this at some later time, my hands are tied right now, need to figure out why some unittests are failing. Thanks for the help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 14 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.