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.  [ 9 posts ] 
Author Message
 Post subject: hbm2java newline/carriage return/linefeed
PostPosted: Wed Oct 26, 2005 7:47 am 
Newbie

Joined: Wed Oct 26, 2005 7:35 am
Posts: 10
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
HibernateTools-3.1.0.beta1

Mapping:

<hibernate-mapping package="gti.domain.generated">

<class name="gti.domain.Sjoerd" abstract="true">
<meta attribute="scope-class">public abstract</meta>
<meta attribute="extends">gti.domain.DbObject</meta>
<meta attribute="generated-class">gti.domain.generated.Sjoerd</meta>

<id name="id" type="java.lang.Long">
<generator class="native" />
</id>

<property name="username" type="string"/>

<set name="n" inverse="true">
<key column="N"/>
<one-to-many class="gti.domain.N"/>
</set>

</class>

<class name="gti.domain.N" abstract="true">
<meta attribute="scope-class">public abstract</meta>
<meta attribute="extends">gti.domain.DbObject</meta>
<meta attribute="generated-class">gti.domain.generated.N</meta>

<id name="id" type="java.lang.Long">
<generator class="native" />
</id>

<property name="jaap" type="string"/>

<many-to-one class="gti.domain.Sjoerd" name="n"/>
</class>

</hibernate-mapping>

ANT:
I use ANT

<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="hibernate.ant.classpath"/>

<hibernatetool>
<configuration configurationfile="${mapping}/hibernate.cfg.xml">
<fileset dir="${mapping}">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>

<hbm2java destdir="${src}"/>

</hibernatetool>


Problem:
When I use hbm2java in hibernate 3 then the genereted import statements does not have a carriage return, it only has a linefeed on windows.
All the other lines have a carriage return linefeed.
How does that work ?
Do I have to confiugre that, or is it a bug?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 7:58 am 
Newbie

Joined: Wed Oct 26, 2005 7:35 am
Posts: 10
I mean that I my generated Source-code does not have a carriege return at the generated import-statement.
So in my VI-editor I see this,

package gti.domain.generated;^M
^M
import gti.domain.Sjoerd;
^M
^M
/**^M
* N generated by hbm2java^M
*/^M
^M
public abstract class N implements java.io.Serializable^M
{^M
^M

As you can see import gti.domain.Sjoerd does not have a ^M (Carraige return). That's the reason the file is converted to Unix-format and will print ^M's. The file will be dosformat when it is full of \n\r's


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 8:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmm - so run it through dos2unix or get an editor that can handle multiple platforms ;)

the reason is because the velocity templates contains the windows style things; you can update them to be more linux friendly.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 7:55 am 
Newbie

Joined: Wed Oct 26, 2005 7:35 am
Posts: 10
Everthing is in Windows-style. The exception is the following generated imports. So for my case

import gti.domain.Sjoerd

is formatted in unix style ( because it does not have a carraige return )


I have looked in the velocity templates and I don't know how I can fix it.

In Pojo.vm I found the following line for import statements:

$secondpassclassimports

That is the velocity tag for ALL the imports, but I don't know where it comes from.
Can you tell me how I can change it, or can you change it ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 10:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
they are done in ImportContextImpl.generateImports(); and they just add \n, but isn't that exactly what you want ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 02, 2005 4:35 am 
Newbie

Joined: Wed Oct 26, 2005 7:35 am
Posts: 10
The whole template uses \r\n so I would like to have it for the import statements too.
So I want to add \r\n in ImportContextImpl.generateImports(); to the import statements.
I'm on a windows machine with cygwin.
My problem is that VI will show a file in unix format if it contains one line which has \n instead of \r\n.
VI shows DOS format if all the lines are in \r\n.

When VI shows the file in unix-format, VI will print ^M for \r

I cannot download the source of the Hibernate-Tools, so I did not see the source code
Can you fix that ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 02, 2005 5:08 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so you basically just want me to always add \r\n. I have committed that, but would be nice to get something in velocity to handle this to make it generate the current os format.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 9:12 am 
Newbie

Joined: Wed Oct 26, 2005 7:35 am
Posts: 10
That's what I want yes.
It's ok that it will be a setting based on OS. But in our case we handle all our files in dos-format. I would like it if this default setting can be customized.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 9:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if you tell me how you can configure velocity to do it then let me know

_________________
Max
Don't forget to rate


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