Publishing failed
Module named 'UneRestServicesEAR' failed to redeploy. See Error Log view for more detail.
Module named 'UneRestServicesEAR' failed to deploy. See Error Log view for more detail.
weblogic.application.ModuleException: org.hibernate.DuplicateMappingException: Same physical table name [UNE_APLICACION_TERCEROS_ROLES] references several logical table names: [APP_3RD_ROLES], [UNE_APLICACION_TERCEROS_ROLES]:org.hibernate.DuplicateMappingException:Same physical table name [UNE_APLICACION_TERCEROS_ROLES] references several logical table names: [APP_3RD_ROLES], [UNE_APLICACION_TERCEROS_ROLES]
Exception received from deployment driver. See Error Log view for more detail.
Module named 'BackChannelEAR' failed to redeploy. See Error Log view for more detail.
Module named 'BackChannelEAR' failed to deploy. See Error Log view for more detail.
weblogic.application.ModuleException: org.hibernate.DuplicateMappingException: Same physical table name [UNE_APLICACION_TERCEROS_ROLES] references several logical table names: [APP_3RD_ROLES], [UNE_APLICACION_TERCEROS_ROLES]:org.hibernate.DuplicateMappingException:Same physical table name [UNE_APLICACION_TERCEROS_ROLES] references several logical table names: [APP_3RD_ROLES], [UNE_APLICACION_TERCEROS_ROLES]
Exception received from deployment driver. See Error Log view for more detail.
Hi!
I'm new here and I'm not very used to Hibernate, so sorry if I ask something obvious.
I'm working in a library for two different projects so I need to use the same code for different physical table names (because in each project I have different name convention requirements).
Everything seemed to be fine using my custom naming strategy, but then I needed to use a jointable in one of the entities and I got stuck with the DuplicateMappingException.
The code is the following.
Naming strategy:
Code:
public class CustomNamingStrategy extends EJB3NamingStrategy {
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(CustomNamingStrategy.class);
private static Properties dataBaseProperties = new Properties();
public void setPropertiesFile(String propertiesFile) {
if(propertiesFile != null) {
try {
InputStream is = CustomNamingStrategy.class.getClassLoader().getResourceAsStream(propertiesFile);
dataBaseProperties.load(is);
} catch (Exception e) {
logger.error("No se pudo cargar el fichero de propiedades [" + propertiesFile + "]");
}
}
}
@Override
public String classToTableName(String className) {
// TODO Auto-generated method stub
String annotatedName = null;
try {
Table table = Entity.class.getAnnotation(Table.class);
annotatedName = table.name();
}
catch(Exception e) {}
String configuredTableName = null;
if(annotatedName != null) configuredTableName = dataBaseProperties.getProperty(BaseDBConstants.CONFIG_TABLE_NAME_PREFIX + annotatedName);
String tableNameToReturn = (configuredTableName != null ? configuredTableName : super.classToTableName(className));
logger.debug("classToTableName: Se devuelve el nombre [{}] para la clase [{}]", tableNameToReturn, className);
return tableNameToReturn;
}
@Override
public String tableName(String tableName) {
String configuredTableName = dataBaseProperties.getProperty(BaseDBConstants.CONFIG_TABLE_NAME_PREFIX + tableName);
String tableNameToReturn = (configuredTableName != null ? configuredTableName : super.tableName(tableName));
logger.debug("tableName: Se devuelve el nombre [{}] para la tabla [{}]", tableNameToReturn, tableName);
return tableNameToReturn;
}
@Override
public String logicalCollectionTableName(String tableName, String ownerEntityTable, String associatedEntityTable, String propertyName) {
String configuredTableName = dataBaseProperties.getProperty(BaseDBConstants.CONFIG_TABLE_NAME_PREFIX + tableName);
String tableNameToReturn = (configuredTableName != null ? configuredTableName : super.logicalCollectionTableName(tableName, ownerEntityTable, associatedEntityTable, propertyName));
logger.debug("logicalCollectionTableName: Se devuelve el nombre [{}] para la tabla [{}]", tableNameToReturn, tableName);
return tableNameToReturn;
}
}
And these are the beans with problems:
Code:
@Entity
@Table(name = "APP_3RD")
public class AplicacionTerceros implements Serializable {
@Id
@Column(name = "ID")
@GeneratedValue(strategy=GenerationType.AUTO, generator="aplicacion_terceros_seg_generator")
@SequenceGenerator(name="aplicacion_terceros_seg_generator", sequenceName="APLICACION_TERCEROS_seq")
private Integer id;
@ManyToMany(fetch= FetchType.EAGER, cascade = CascadeType.ALL)
@JsonIgnore
@JoinTable(
name="APP_3RD_ROLES",
joinColumns=@JoinColumn(name="APP_ID", referencedColumnName= "ID", nullable=true, updatable = true, insertable=true),
inverseJoinColumns=@JoinColumn(name="ROLE", referencedColumnName = "ROLE", insertable=true, updatable = true, nullable = true)
)
private Set<Role> rolesPermitidos = new HashSet<Role>();
@Column(name = "APP_ID")
private Integer appId;
...
}
Code:
@Entity
@Table(name = "APP_3RD_ROLES")
public class AppRoleConfig implements java.io.Serializable {
private AppRoleId id;
private Role role;
private AplicacionTerceros app;
...
}
I'm using Spring, and everytime I try to deploy the app, I get the following error:
Quote:
org.hibernate.DuplicateMappingException: Same physical table name [APLICACION_TERCEROS_ROLES] references several logical table names: [APP_3RD_ROLES], [APLICACION_TERCEROS_ROLES]
Am I doing something wrong? Is it a bug?
Thank you all in advance!