-->
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.  [ 2 posts ] 
Author Message
 Post subject: prefix attribute of @hibernate.component tag not working
PostPosted: Tue Aug 02, 2005 6:05 am 
Newbie

Joined: Wed Jul 20, 2005 11:32 am
Posts: 7
Hi,

I am trying to generate hibernate mapping files and ddl using hibernatedoclet and hbm2ddl.

I have a class with a component DateRange as an attribute which has two properties - start and end dates.

The persistent class in question has two attributes of type DateRange - accessibleTime and .

When I use the hibernatedoclet tag along with prefix option on the accessibleTime and effectivityPeriod attributes, the mapping file generated does not have any prefix option and the DDL generated only picks up start_dt & end_dt for one time without any prefixes.

The code is given below. Please let me know if I am doing something wrong or there is a bug in the prefix attribute for @hibernate.component
**************************
Java Code for Persistent class

public class ContactPerson {

private DateRange accessibleTime;
private DateRange effectivityPeriod;
private Integer objectID;

/**
* @hibernate.id column="ObjectID" generator-class="sequence"
*
*/
public Integer getObjectID() {
return objectID;
}

/**
* @param String
*/
public void setPartyID(Integer partyID) {
this.objectID = partyID;
}

/**
* @hibernate.component class="nl.rabobank.rn.cpl.bec.party.DateRange" prefix="acc"
*/
public DateRange getAccessibleTime() {
return accessibleTime;
}

public void setAccessibleTime(DateRange accessibleTime) {
this.accessibleTime = accessibleTime;
}

/**
* @hibernate.component class="nl.rabobank.rn.cpl.bec.party.DateRange" prefix="eff"
*/
public DateRange getEffectivityPeriod() {
return effectivityPeriod;
}

public void setEffectivityPeriod(DateRange effectivityPeriod) {
this.effectivityPeriod = effectivityPeriod;
}
}
*********************
Java code for component class -

import java.sql.Timestamp;
public class DateRange {
private Timestamp startDate;
private Timestamp endDate;
public Timestamp getEndDate() {
return endDate;
}
public void setEndDate(Timestamp endDate) {
this.endDate = endDate;
}
public Timestamp getStartDate() {
return startDate;
}
public void setStartDate(Timestamp startDate) {
this.startDate = startDate;
}
}
*********************
Generated Hibernate File
<hibernate-mapping>
<class name="com.test" table="ContactPerson">

<id name="objectID" column="ObjectID" type="java.lang.Integer">
<generator class="sequence"/>
</id>

<component name="accessibleTime" class="nl.rabobank.rn.cpl.bec.party.DateRange">
<property name="endDate" type="java.sql.Timestamp" update="true" insert="true" column="end_dt"/>
<property name="startDate" type="java.sql.Timestamp" update="true" insert="true" column="start_dt"/>
</component>

<component name="effectivityPeriod" class="nl.rabobank.rn.cpl.bec.party.DateRange">
<property name="endDate" type="java.sql.Timestamp" update="true" insert="true" column="end_dt"/>
<property name="startDate" type="java.sql.Timestamp" update="true" insert="true" column="start_dt"/>
</component>
</class>
</hibernate-mapping>
*********************
Generated DDL -

create table ContactPerson (ObjectID number(10,0) not null, end_dt timestamp, start_dt timestamp, primary key (ObjectID))
*********************
Hibernate version: 3.0

Name and version of the database you are using:Oracle10g

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 8:19 am 
Newbie

Joined: Thu May 13, 2004 8:56 am
Posts: 9
Location: Cape Town, South Africa
You should add @hibernate mappings in the component class, e.g:

Code:
import java.sql.Timestamp;
public class DateRange {
private Timestamp startDate;
private Timestamp endDate;
/**
* @hibernate.property
*/
public Timestamp getEndDate() {
return endDate;
}
public void setEndDate(Timestamp endDate) {
this.endDate = endDate;
}
/**
* @hibernate.property
*/
public Timestamp getStartDate() {
return startDate;
}
public void setStartDate(Timestamp startDate) {
this.startDate = startDate;
}
}


That's what I do and it works.


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