-->
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.  [ 3 posts ] 
Author Message
 Post subject: @Type question??
PostPosted: Mon Apr 25, 2005 5:40 am 
Newbie

Joined: Fri Apr 01, 2005 1:05 am
Posts: 10
Location: China
I use hibernate3 and hibernate-annotation in my work

I define a immutable class which name is DateRange,it has two property mapping two column in table. I also define a class DateRangeType which implements CompositeUserType.My question is : how can i writting annotation in order to mapping DateRange to two column in table? I just write like that:

package com.star.sms.model.ppvcatalogue;

import java.util.Date;

import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratorType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.OptimisticLockType;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;

import com.star.common.customtype.hibernate.DateRangeType;
import com.star.common.customtype.hibernate.StandEnumType;
import com.star.common.customtype.hibernate.StringValueEnumType;
import com.star.common.lang.DateRange;
import com.star.sms.model.core.AbstractHibernateEntity;
import com.star.sms.model.core.Operator;

@Entity()
@Table(name="PPVPRICE")
@org.hibernate.annotations.Entity(
selectBeforeUpdate = false,
dynamicInsert = true,
dynamicUpdate = true,
optimisticLock = OptimisticLockType.VERSION
)
@TypeDefs(
{
@TypeDef(
name="DateRange",
typeClass = DateRangeType.class
)
}
)
public class PpvPrice extends AbstractHibernateEntity {

private Integer priceTypeId;

private String priceType;

private Double price;

private Date creatDate;

private String mem;

private DateRange priceDateRange;

public PpvPrice() {
super(new String[]{"getPriceTypeId"});
}

@Column(updatable = false, insertable = true,
unique = false, name = "CREATDT",
nullable = false)
public Date getCreatDate() {
return creatDate;
}

public void setCreatDate(Date creatDate) {
this.creatDate = creatDate;
}

@Column(updatable = true, insertable = true,
unique = false, name = "MEM",
nullable = true)
public String getMem() {
return mem;
}

public void setMem(String mem) {
this.mem = mem;
}

@Column(updatable = true, insertable = true,
unique = false, name = "PRICE",
nullable = true, length=6, precision=2)
public Double getPrice() {
return price;
}

public void setPrice(Double price) {
this.price = price;
}

@Type(type="DateRange")
public DateRange getPriceDateRange() {
return priceDateRange;
}

public void setPriceDateRange(DateRange priceDateRange) {
this.priceDateRange = priceDateRange;
}

@Column(updatable = true, insertable = true,
unique = false, name = "RICETYPESTR",
nullable = false)
public String getPriceType() {
return priceType;
}

public void setPriceType(String priceType) {
this.priceType = priceType;
}

@Id(generate=GeneratorType.AUTO)
public Integer getPriceTypeId() {
return priceTypeId;
}

public void setPriceTypeId(Integer priceTypeId) {
this.priceTypeId = priceTypeId;
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 02, 2005 5:31 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is currently not possible. It's in the todo list though

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 16, 2005 2:33 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Now possible in CVS using @Columns

_________________
Emmanuel


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