-->
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.  [ 11 posts ] 
Author Message
 Post subject: Issue with DB reverse engineering with Hibernate IDE builds
PostPosted: Sun Jun 18, 2006 11:21 am 
Newbie

Joined: Sun Jun 18, 2006 11:02 am
Posts: 5
Hi

The reverse engineering for attributes is not working

X_AXIS_LABEL
Y_AXIS_LABEL

the hbm file is being incorrectly generated.

Thanks & Regards
Ramesh


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 18, 2006 11:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you need to be more specific/informative.

e.g. what is wrong with mapping files ? You just show 2 column names that looks perfectly fine ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 18, 2006 11:34 am 
Newbie

Joined: Sun Jun 18, 2006 11:02 am
Posts: 5
Hi Max -

If the columns names are X_AXIS_LABEL and Y_AXIS_LABEL the generated domain object is having XAxisLable and YAxisLabel as properties instead of
xAxisLabel and yAxisLabel.

And if I manually change the properties to xAxisLabel and yAxisLabel the Configuration is reporting error though the bean generation is happening in eclipse.

<property name="XAxisLabel" type="string">
<column name="X_AXIS_LABEL" length="45" />
</property>
<property name="YAxisLabel" type="string">
<column name="Y_AXIS_LABEL" length="45" />
</property>

private String XAxisLabel;
private String YAxisLabel;

Please let me know if any more information is needed. I dont think this will be specific to some eclipse version.

Thanks for the quick response!!! Really wonderful!!!

Regards
Ramesh


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 18, 2006 12:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well this is a small quirk with the javabeans spec regarding naming of properties.

if you want that to be different implement ReverseEngineeringStrategy and its columnToName.

but check what hibernate accepts/wants first.

if my memory serves me correctly then XAxisLabel is actually the correct *property* name, since e.g. the get method is named getXAxisLabel.

btw. I don't understand why you say it is incorrecty generated ?

Did the resulting mapping files not work outofthebox or is it just your personal preference that it went against ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 18, 2006 1:43 pm 
Newbie

Joined: Sun Jun 18, 2006 11:02 am
Posts: 5
Hi Max

The Java Bean spec says the attributes set/get methods will follow

set + attribute with first letter Upper case

so XAxisLabel will have setXAxisLabel. Which is expected result.

But there is the issue with the convension. The attributes must start with small letter. While reverse engineering this is turning to XAxisLabel instead of xAxisLabel.

Second if I change the attributes as xAxisLable instead of XAxisLabel in all the places(Bean definition, hbm file, set and get methods) in Eclipse -> Hibernate Configurations view is show as error:

Details:
<Sessionfactory error: Could not find a getter for yAxisLabel in org.ascendant.jreport.domain.JrChart>

And hibernate Code Generation wizard generating the code only as YAxisLabel.

Regards
Ramesh


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 18, 2006 3:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
stop - consecutive upper case letters have special consideration (e.g. URL does not become uRl similar that XAxisLabel does not become xAxisLabel)...but since you have a _ between the first two in the initial column it is a bit different.

So two simple questions:

1) Does the output *run* out of the box

2) if not, what is the actual output ?

...and changing all the places is definitly not the correct thing ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 18, 2006 3:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
...in short just *show* the outputted code instead of explaining the output - alot of ambiguity is possible in explanations of code ;)

thanks.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 18, 2006 9:11 pm 
Newbie

Joined: Sun Jun 18, 2006 11:02 am
Posts: 5
Hi Max -

Here is the output:

HBM File:

<?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 Jun 18, 2006 9:07:03 PM by Hibernate Tools 3.1.0.beta4 -->
<hibernate-mapping>
<class name="org.ascendant.jreport.domain.JrChart" table="jr_chart" catalog="jreports">
<id name="chartId" type="long">
<column name="CHART_ID" />
<generator class="assigned" />
</id>
<version name="version" type="java.lang.Integer">
<column name="VERSION" />
</version>
<property name="chartName" type="string">
<column name="CHART_NAME" length="45" />
</property>
<property name="description" type="string">
<column name="DESCRIPTION" />
</property>
<property name="chartType" type="java.lang.Integer">
<column name="CHART_TYPE" />
</property>
<property name="XAxisLabel" type="string">
<column name="X_AXIS_LABEL" length="45" />
</property>
<property name="YAxisLabel" type="string">
<column name="Y_AXIS_LABEL" length="45" />
</property>
<property name="width" type="java.lang.Integer">
<column name="WIDTH" />
</property>
<property name="height" type="java.lang.Integer">
<column name="HEIGHT" />
</property>
<property name="createdDate" type="timestamp">
<column name="CREATED_DATE" length="19" />
</property>
<property name="updatedDate" type="timestamp">
<column name="UPDATED_DATE" length="19" />
</property>
<property name="createdBy" type="string">
<column name="CREATED_BY" length="45" />
</property>
<property name="updatedBy" type="string">
<column name="UPDATED_BY" length="45" />
</property>
<property name="active" type="java.lang.Boolean">
<column name="ACTIVE" />
</property>
<set name="jrReports" inverse="true">
<key>
<column name="CHART_ID" not-null="true" />
</key>
<one-to-many class="org.ascendant.jreport.domain.JrReport" />
</set>
</class>
</hibernate-mapping>


The file generated:

package org.ascendant.jreport.domain;
// Generated Jun 18, 2006 9:07:04 PM by Hibernate Tools 3.1.0.beta4

import java.util.Date;
import java.util.HashSet;
import java.util.Set;


/**
* JrChart generated by hbm2java
*/

public class JrChart implements java.io.Serializable {


// Fields

private long chartId;
private Integer version;
private String chartName;
private String description;
private Integer chartType;
private String XAxisLabel;
private String YAxisLabel;
private Integer width;
private Integer height;
private Date createdDate;
private Date updatedDate;
private String createdBy;
private String updatedBy;
private Boolean active;
private Set<JrReport> jrReports = new HashSet<JrReport>(0);


// Constructors

/** default constructor */
public JrChart() {
}

/** minimal constructor */
public JrChart(long chartId) {
this.chartId = chartId;
}

/** full constructor */
public JrChart(long chartId, String chartName, String description, Integer chartType, String XAxisLabel, String YAxisLabel, Integer width, Integer height, Date createdDate, Date updatedDate, String createdBy, String updatedBy, Boolean active, Set<JrReport> jrReports) {
this.chartId = chartId;
this.chartName = chartName;
this.description = description;
this.chartType = chartType;
this.XAxisLabel = XAxisLabel;
this.YAxisLabel = YAxisLabel;
this.width = width;
this.height = height;
this.createdDate = createdDate;
this.updatedDate = updatedDate;
this.createdBy = createdBy;
this.updatedBy = updatedBy;
this.active = active;
this.jrReports = jrReports;
}



// Property accessors

public long getChartId() {
return this.chartId;
}

public void setChartId(long chartId) {
this.chartId = chartId;
}

public Integer getVersion() {
return this.version;
}

public void setVersion(Integer version) {
this.version = version;
}

public String getChartName() {
return this.chartName;
}

public void setChartName(String chartName) {
this.chartName = chartName;
}

public String getDescription() {
return this.description;
}

public void setDescription(String description) {
this.description = description;
}

public Integer getChartType() {
return this.chartType;
}

public void setChartType(Integer chartType) {
this.chartType = chartType;
}

public String getXAxisLabel() {
return this.XAxisLabel;
}

public void setXAxisLabel(String XAxisLabel) {
this.XAxisLabel = XAxisLabel;
}

public String getYAxisLabel() {
return this.YAxisLabel;
}

public void setYAxisLabel(String YAxisLabel) {
this.YAxisLabel = YAxisLabel;
}

public Integer getWidth() {
return this.width;
}

public void setWidth(Integer width) {
this.width = width;
}

public Integer getHeight() {
return this.height;
}

public void setHeight(Integer height) {
this.height = height;
}

public Date getCreatedDate() {
return this.createdDate;
}

public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}

public Date getUpdatedDate() {
return this.updatedDate;
}

public void setUpdatedDate(Date updatedDate) {
this.updatedDate = updatedDate;
}

public String getCreatedBy() {
return this.createdBy;
}

public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}

public String getUpdatedBy() {
return this.updatedBy;
}

public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}

public Boolean getActive() {
return this.active;
}

public void setActive(Boolean active) {
this.active = active;
}

public Set<JrReport> getJrReports() {
return this.jrReports;
}

public void setJrReports(Set<JrReport> jrReports) {
this.jrReports = jrReports;
}

}

Thanks & Regards
Ramesh


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 8:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
ok - i don't see anything wrong with this code - it should run just fine.

Is it the *fields* naming you don't like ? Then there is no problem in changing them (and just them) since hibernate does not look at the fields but at the property name in hbm.xml + the getter/setter names which are in sync afaik.

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 11:06 am 
Newbie

Joined: Sun Jun 18, 2006 11:02 am
Posts: 5
Hi Max-

The issue is, even if I change the property name as xAxisLabel and yAxisLabel and corresponding entries in the .hbm file, the issue persist with Eclipse Hibernate Configuration View ( Hibernate Configuration from Show Views in the menu).

If u can give an e-mail by EOD I can send you a snapshot.

Thanks for the prompt reply. I really appreciate it :).

Kind regards
Ramesh


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 20, 2006 4:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
show me what you *change* it to.

I don't get why you say you are also changing it in the getters/hbm.xml - that seems wrong. So show the lines you actually want to change.

_________________
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.  [ 11 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.