-->
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.  [ 4 posts ] 
Author Message
 Post subject: Annotations: is there a way to set a prefix for embeddeed?
PostPosted: Sat Oct 22, 2005 7:21 am 
Regular
Regular

Joined: Wed May 05, 2004 8:01 am
Posts: 53
Is there a possibility to annotate an embedded component to use some prefix to be applied to column name? otherwise if you include a component more than once in the same entity you get name clashes.

example:

Code:
@Embeddable
public class RouteInfo {
    private Date   time;
    private Double   counterValue;
    private Double   cashAmount;

    // getters and setters here
}


@Entity
public class Route extends Persistent {
    private RouteDefinition routeDefinition;
    private String          note;

    private RouteInfo       startInfo   = new RouteInfo();

    private RouteInfo       finishInfo  = new RouteInfo();

    @Embedded
    @AttributeOverrides({ @AttributeOverride(name = "time", column = @Column(name = "start_time")),
                    @AttributeOverride(name = "cashAmount", column = @Column(name = "start_cashAmount")),
                    @AttributeOverride(name = "counterValue", column = @Column(name = "start_counterValue")) })
    public RouteInfo getStartInfo() {
        return startInfo;
    }

    @Embedded
    @AttributeOverrides({ @AttributeOverride(name = "time", column = @Column(name = "finish_time")),
                    @AttributeOverride(name = "cashAmount", column = @Column(name = "finish_cashAmount")),
                    @AttributeOverride(name = "counterValue", column = @Column(name = "finish_counterValue")) })
    public RouteInfo getFinishInfo() {
        return finishInfo;
    }

    // more getters and setters here
}


Any way to make it shorter? Annotations docs does not mention any possibility.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 23, 2005 4:59 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It's on my target through the NamingStrategy. there is an open JIRA on this

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 24, 2005 8:02 am 
Newbie

Joined: Mon Oct 24, 2005 7:58 am
Posts: 1
Location: South Africa
Awesome, so we'll be able to do this :

Code:
@Embeddable
public class RouteInfo {
    private Date   time;
    private Double   counterValue;
    private Double   cashAmount;

    // getters and setters here
}


@Entity(access=AccessType.FIELD)
public class Route extends Persistent {
    private RouteDefinition routeDefinition;
    private String          note;

    private RouteInfo       startInfo;

    private RouteInfo       finishInfo;

    // more getters and setters here
}


soon?

_________________
"The power of faith is quiet. It is the leaf unmoved by a hurricane."


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 8:08 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I've commited it in HEAD as org.hibernate.test.annotations.strategy.DefaultComponentSafeNamingStrategy

_________________
Emmanuel


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