Hibernate throws an exception when creating the tables, because embedded attributes are mapped to the same column.
The class Distance is embedded twice in a class route as followed:
@Embeddable
public class Distance implements Serializable{
private static final long serialVersionUID = -8466495790824502626L;
@Column(nullable = false)
protected Integer distInSec;
public Distance() {
super();
}
}
@Entity
public class Route{
@Column(nullable=false)
protected Distance currentDetour;
@Column(nullable=false)
protected Distance currentDist;
}
When hibernate creates the table, it tries to map distInSec of currentDetour as well as of currentDist to the same column “distInSec” in the table route. Hence, the error org.hibernate.MappingException: Repeated column in mapping for entity: is thrown.
If possible I would like to change the configuration in the way that it always produces colums with the names currentDetour_distInSec and currentDist_distInSec. Does anybody have an idea how to do so?
Thanks in advance
using DefaultComponentSafeNamingStrategy as the naming strategy solved the issue