Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

OneToMany Relationship : Help

643071Jun 4 2008 — edited Jun 4 2008
Hi,

I am just a beginner in toplink and stuck in a problem for long time.

I have two tables MGMT_EVENT_RULES and MGMT_EVENT_RULE_CONFIGS and I would like to establish OneToMany (bidirectional) relationship between them.

I created two entity classes MgmtEventRule and MgmtEventRuleConfig which are mapped to above tables resp.

Relationship:

/***********************************************************************/
Entity1:

@Entity
@Table(name="MGMT_EVENT_RULE_CONFIG")
@IdClass(eventrule.MgmtEventRuleConfigID.class)
public class MgmtEventRuleConfig implements java.io.Serializable {
.
.
.
//getter setters

private MgmtEventRule mgmtEventRule;

@ManyToOne
@JoinColumn(name = "rule_guid", nullable = false)
public MgmtEventRule getMgmtEventRule() {
return mgmtEventRule;
}

public void setMgmtEventRule(MgmtEventRule mgmtEventRule) {
this.mgmtEventRule = mgmtEventRule;
}

.
.
.
}

/*********************************************************************/
Entity2:

@Entity
@Table(name="MGMT_EVENT_RULES")
public class MgmtEventRule implements java.io.Serializable {
.
.
.
//getter setter

private List<MgmtEventRuleConfig> mgmtEventRuleConfigs;

@OneToMany(cascade=CascadeType.ALL, mappedBy="rule_guid")
@JoinTable(name="MGMT_EVENT_RULE_CONFIG")
public List<MgmtEventRuleConfig> getMgmtEventRuleConfigs(){
return mgmtEventRuleConfigs;
}

.
.
.
}

/************************************************************************/
Class in which I am querying has a read() method

public void read(){
try{
List<MgmtEventRule> list = em.createQuery("select mer from MgmtEventRule mer").getResultList();
for(MgmtEventRule mer :list){
for(MgmtEventRuleConfig con : mer.getMgmtEventRuleConfigs()){
System.out.println(con);
} System.out.println(mer);
}

} catch(NoResultException e){
System.out.println("Nothing Returned");
}
}

/******************************************************************************/
On running I am getting following error.Please note that I am able to display select results for each entity.But problem is in the relationship.Any kind of help would be highly appreciated.


[TopLink Info]: 2008.06.04 03:23:24.844--ServerSession(13459339)--TopLink, version: Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))
[TopLink Info]: 2008.06.04 03:23:46.094--ServerSession(13459339)--file:/C:/Documents%20and%20Settings/pujain/My%20Documents/NetBeansProjects/EventRule/build/classes/-Mgmt_Event_Rule login successful
Exception in thread "main" Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-00972: identifier is too long

Error Code: 972
Call: SELECT t1.ATTR_NAME, t1.ATTR_VALUE, t1.EVENT_TYPE, t1.OPERATOR_CODE, t1.RULE_GUID, t1.RULE_CONFIG_ID, t1.rule_guid FROM MGMT_EVENT_RULES_MGMT_EVENT_RULE_CONFIG t0, MGMT_EVENT_RULE_CONFIG t1 WHERE ((t0.MgmtEventRule_RULE_GUID = ?) AND ((t1.RULE_CONFIG_ID = t0.RULE_CONFIG_ID) AND ((t1.RULE_GUID = t0.RULE_GUID) AND ((t1.OPERATOR_CODE = t0.OPERATOR_CODE) AND ((t1.EVENT_TYPE = t0.EVENT_TYPE) AND ((t1.ATTR_VALUE = t0.ATTR_VALUE) AND (t1.ATTR_NAME = t0.ATTR_NAME)))))))
bind => [[B@8ab08f]
Query: ReadAllQuery(eventrule.MgmtEventRuleConfig)
at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:304)
[TopLink Warning]: 2008.06.04 03:23:50.734--ServerSession(13459339)--Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-00972: identifier is too long

Error Code: 972
Call: SELECT t1.ATTR_NAME, t1.ATTR_VALUE, t1.EVENT_TYPE, t1.OPERATOR_CODE, t1.RULE_GUID, t1.RULE_CONFIG_ID, t1.rule_guid FROM MGMT_EVENT_RULES_MGMT_EVENT_RULE_CONFIG t0, MGMT_EVENT_RULE_CONFIG t1 WHERE ((t0.MgmtEventRule_RULE_GUID = ?) AND ((t1.RULE_CONFIG_ID = t0.RULE_CONFIG_ID) AND ((t1.RULE_GUID = t0.RULE_GUID) AND ((t1.OPERATOR_CODE = t0.OPERATOR_CODE) AND ((t1.EVENT_TYPE = t0.EVENT_TYPE) AND ((t1.ATTR_VALUE = t0.ATTR_VALUE) AND (t1.ATTR_NAME = t0.ATTR_NAME)))))))
bind => [[B@8ab08f]
Query: ReadAllQuery(eventrule.MgmtEventRuleConfig)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:551)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:437)
at oracle.toplink.essentials.threetier.ServerSession.executeCall(ServerSession.java:465)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:213)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:199)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:270)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:600)
at oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2240)
at oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2218)
at oracle.toplink.essentials.queryframework.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:302)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:709)
at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:677)
at oracle.toplink.essentials.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:1815)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)
at oracle.toplink.essentials.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:86)
at oracle.toplink.essentials.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:76)
at oracle.toplink.essentials.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:90)
at oracle.toplink.essentials.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:160)
at oracle.toplink.essentials.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:232)
at oracle.toplink.essentials.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:90)
at oracle.toplink.essentials.indirection.IndirectList.buildDelegate(IndirectList.java:193)
at oracle.toplink.essentials.indirection.IndirectList.getDelegate(IndirectList.java:315)
at oracle.toplink.essentials.indirection.IndirectList$1.<init>(IndirectList.java:410)
at oracle.toplink.essentials.indirection.IndirectList.iterator(IndirectList.java:409)
at eventrule.ShowResults.read(ShowResults.java:32)
at eventrule.ShowResults.main(ShowResults.java:54)
Caused by: java.sql.SQLException: ORA-00972: identifier is too long

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:813)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1049)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:854)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1154)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3415)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:711)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:486)
... 26 more



/*************************************************************************************************/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 2 2008
Added on Jun 4 2008
1 comment
2,112 views