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?