-->
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: DefaultComponentSafeNamingStrategy?
PostPosted: Fri Jun 09, 2006 6:00 pm 
Newbie

Joined: Thu Oct 07, 2004 9:41 pm
Posts: 5
From this thread (http://forum.hibernate.org/viewtopic.ph ... teoverride) it looked like DefaultComponentSafeNamingStrategy might be the solution to having multiple components of the same type in a class.

I have however been unable to find it in the latest (3.2.0 RC1) version of the annotations.

Does anyone know what happened to it?

I can use @AttributeOverride to override column names provided the component does not have any relationships to other entities, but if they do, it seems that the override is ignored.

In other words,building on the example in the previous thread, this does not seem to work:

Code:
@Entity
public class Router {
    private long id;
    private String name;

    //getters and setters here
}

@Embeddable
public class RouteInfo {
    private Date   time;
    private Double   counterValue;
    private Double   cashAmount;
    Router theRouter;

    @OneToOne
    public getRouter()
    {
        return theRouter;
    }

    // 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 = "router.ID",    column = @Column(name = "start_routerID")),
@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 = "router.ID",    column = @Column(name = "finish_routerID")),
@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
}



Is there another way to accomplish this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 09, 2006 6:38 pm 
Newbie

Joined: Thu Oct 07, 2004 9:41 pm
Posts: 5
Of course, 5 minutes after posting this I find the solution.

DefaultComponentSafeNamingStrategy is a configuration time property that needs to be set before calling buildSessionFactory, and it neatly solves my problem.


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.