ORA-00942: table or view does not exist

456 views
Skip to first unread message

Gregory Kaidanov

unread,
Jan 24, 2010, 8:26:15 AM1/24/10
to Fluent NHibernate, ste...@rnbsolutions.net
Hello ,
I'm trying to establish HasManyToMany between 2 tables in my legacy
Oracle db:


HasManyToMany<YechidaGroup>(x => x.Col_yig)
.ChildKeyColumn("YIG_GROUP_RECID")
.ParentKeyColumn("PIG_GROUP_RECID")
.Fetch.Select() ;

It creates an alias for the association join by name
"YechidaGroupToProductsGroup" and in the output of my test , when I
am trying to reach the children's collection I'm getting
---> System.Data.OracleClient.OracleException: ORA-00942: table or
view does not exist


full output stack :
------ Test started: Assembly: Ness.DoarKamuti.DataLayer.Tests.dll
------

TestCase
'M:Ness.DoarKamuti.DataLayer.Tests.ProductsGroupMappingTests.TestProductsGroupMapping'
failed: could not initialize a collection:
[Ness.DoarKamuti.Infrastructure.Entities.ProductsGroup.Col_yig#403]
[SQL: SELECT col_yig0_."PIG_GROUP_RECID" as PIG1_2_,
col_yig0_."YIG_GROUP_RECID" as YIG2_2_, yechidagro1_."YIG_RECID" as
YIG1_29_0_, yechidagro1_."YIG_FROM_TOKEF" as YIG2_29_0_,
yechidagro1_."YIG_UNTIL_TOKEF" as YIG3_29_0_,
yechidagro1_."YIG_YECHIDAID" as YIG4_29_0_,
yechidagro1_."YIG_GROUP_RECID" as YIG5_29_0_,
yechidatdo2_."YDR_YECHIDAT_DOARID" as YDR1_14_1_,
yechidatdo2_."YDR_DELIVERYNUM" as YDR2_14_1_ FROM
YechidaGroupToProductsGroup col_yig0_ left outer join
T_YECHIDOT_DOAR_IN_GROUP yechidagro1_ on
col_yig0_."YIG_GROUP_RECID"=yechidagro1_."YIG_RECID" left outer join
YECHIDAT_DOAR yechidatdo2_ on
yechidagro1_."YIG_YECHIDAID"=yechidatdo2_."YDR_YECHIDAT_DOARID" WHERE
col_yig0_."PIG_GROUP_RECID"=?]
NHibernate.Exceptions.GenericADOException: could not initialize a
collection:
[Ness.DoarKamuti.Infrastructure.Entities.ProductsGroup.Col_yig#403]
[SQL: SELECT col_yig0_."PIG_GROUP_RECID" as PIG1_2_,
col_yig0_."YIG_GROUP_RECID" as YIG2_2_, yechidagro1_."YIG_RECID" as
YIG1_29_0_, yechidagro1_."YIG_FROM_TOKEF" as YIG2_29_0_,
yechidagro1_."YIG_UNTIL_TOKEF" as YIG3_29_0_,
yechidagro1_."YIG_YECHIDAID" as YIG4_29_0_,
yechidagro1_."YIG_GROUP_RECID" as YIG5_29_0_,
yechidatdo2_."YDR_YECHIDAT_DOARID" as YDR1_14_1_,
yechidatdo2_."YDR_DELIVERYNUM" as YDR2_14_1_ FROM
YechidaGroupToProductsGroup col_yig0_ left outer join
T_YECHIDOT_DOAR_IN_GROUP yechidagro1_ on
col_yig0_."YIG_GROUP_RECID"=yechidagro1_."YIG_RECID" left outer join
YECHIDAT_DOAR yechidatdo2_ on
yechidagro1_."YIG_YECHIDAID"=yechidatdo2_."YDR_YECHIDAT_DOARID" WHERE
col_yig0_."PIG_GROUP_RECID"=?] --->
System.Data.OracleClient.OracleException: ORA-00942: table or view
does not exist

at System.Data.OracleClient.OracleConnection.CheckError
(OciErrorHandle errorHandle, Int32 rc)
at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle
statementHandle, CommandBehavior behavior, Boolean needRowid,
OciRowidDescriptor& rowidDescriptor, ArrayList&
resultParameterOrdinals)
at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle
statementHandle, CommandBehavior behavior, ArrayList&
resultParameterOrdinals)
at System.Data.OracleClient.OracleCommand.ExecuteReader
(CommandBehavior behavior)
at System.Data.OracleClient.OracleCommand.ExecuteDbDataReader
(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader
()
at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean
autoDiscoverTypes, Boolean callable, RowSelection selection,
ISessionImplementor session)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session,
QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections
(ISessionImplementor session, QueryParameters queryParameters, Boolean
returnProxies)
at NHibernate.Loader.Loader.LoadCollection(ISessionImplementor
session, Object id, IType type)
--- End of inner exception stack trace ---
at NHibernate.Loader.Loader.LoadCollection(ISessionImplementor
session, Object id, IType type)
at NHibernate.Loader.Collection.CollectionLoader.Initialize(Object
id, ISessionImplementor session)
at
NHibernate.Persister.Collection.AbstractCollectionPersister.Initialize
(Object key, ISessionImplementor session)
at
NHibernate.Event.Default.DefaultInitializeCollectionEventListener.OnInitializeCollection
(InitializeCollectionEvent event)
at NHibernate.Impl.SessionImpl.InitializeCollection
(IPersistentCollection collection, Boolean writing)
at NHibernate.Collection.AbstractPersistentCollection.Initialize
(Boolean writing)
at NHibernate.Collection.AbstractPersistentCollection.Read()
at NHibernate.Collection.AbstractPersistentCollection.ReadSize()
at NHibernate.Collection.PersistentBag.get_Count()
C:\NetProjects\NESS\Ness.DoarKamuti\Ness.DoarKamuti.DataLayer.Tests
\MappingTests\ProductsGroupMappingTests.cs(29,0): at
Ness.DoarKamuti.DataLayer.Tests.ProductsGroupMappingTests.TestProductsGroupMapping
()

2010-01-24 15:12:00,951 [TestRunnerThread] DEBUG NHibernate.SQL -
SELECT productsgr0_."PIG_RECID" as PIG1_30_0_,
productsgr0_."PIG_FROM_TOKEF" as PIG2_30_0_,
productsgr0_."PIG_GROUP_RECID" as PIG3_30_0_,
productsgr0_."PIG_PRODUCTID" as PIG4_30_0_,
productsgr0_."PIG_UNTIL_TOKEF" as PIG5_30_0_ FROM T_PRODUCTS_IN_GROUP
productsgr0_ WHERE productsgr0_."PIG_RECID"=:p0;:p0 = 403
2010-01-24 15:12:01,091 [TestRunnerThread] DEBUG NHibernate.SQL -
SELECT col_yig0_."PIG_GROUP_RECID" as PIG1_2_,
col_yig0_."YIG_GROUP_RECID" as YIG2_2_, yechidagro1_."YIG_RECID" as
YIG1_29_0_, yechidagro1_."YIG_FROM_TOKEF" as YIG2_29_0_,
yechidagro1_."YIG_UNTIL_TOKEF" as YIG3_29_0_,
yechidagro1_."YIG_YECHIDAID" as YIG4_29_0_,
yechidagro1_."YIG_GROUP_RECID" as YIG5_29_0_,
yechidatdo2_."YDR_YECHIDAT_DOARID" as YDR1_14_1_,
yechidatdo2_."YDR_DELIVERYNUM" as YDR2_14_1_ FROM
YechidaGroupToProductsGroup col_yig0_ left outer join
T_YECHIDOT_DOAR_IN_GROUP yechidagro1_ on
col_yig0_."YIG_GROUP_RECID"=yechidagro1_."YIG_RECID" left outer join
YECHIDAT_DOAR yechidatdo2_ on
yechidagro1_."YIG_YECHIDAID"=yechidatdo2_."YDR_YECHIDAT_DOARID" WHERE
col_yig0_."PIG_GROUP_RECID"=:p0;:p0 = 403

0 passed, 1 failed, 0 skipped, took 12.53 seconds (Ad hoc).

-------------------------------------------------------------------------------------------------
The question is , how can I map my 2 tables as Many to Many not
through Id comparison and still get the result of join ?

p.s.
There is an issue with #164 build of Fluent Nhibernate , making as to
map
like this
Map(x => x.Pig_group_recid).Column("PIG_GROUP_RECID");
instead of
Map(x => x.Pig_group_recid);
Otherwise FNH doesn't recognize the columns , even though they were
mapped properly .

Hudson Akridge

unread,
Jan 24, 2010, 10:18:48 AM1/24/10
to fluent-n...@googlegroups.com
You need to do a .PropertyRef() if you're joining to the join table on a non-id. PropertyRef expects the propertyname, not the column name. To specify your join table, you use .Table("LegacyJoinTable").

Build 164 I believe has an issue with quoting column names, where quoting making the columns case sensitive, so a "Pig_group_recid" doesn't work in place of the all caps one (which is probably what is defined in the database). 


--
You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group.
To post to this group, send email to fluent-n...@googlegroups.com.
To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.




--
- Hudson
http://www.bestguesstheory.com
http://twitter.com/HudsonAkridge

Gregory Kaidanov

unread,
Jan 24, 2010, 10:43:17 AM1/24/10
to Fluent NHibernate

HasMany<YechidaGroup>(x => x.Col_yig).AsBag()
.KeyColumn("YIG_GROUP_RECID")
.PropertyRef("Pig_group_recid");
does work , but I would like to have a many-to-many relationship.
Can you provide some syntax example ?

p.s.
Some other issue that is interesting , nevertheless I am lazyLoading
the collections are being recognized only at the child level ,
and not at the grandchild's . It seems , that FNH can not initialize
lazy loading no matter what I do.

Thanks for the reply.

On Jan 24, 5:18 pm, Hudson Akridge <hudson.akri...@gmail.com> wrote:
> You need to do a .PropertyRef() if you're joining to the join table on a
> non-id. PropertyRef expects the propertyname, not the column name. To
> specify your join table, you use .Table("LegacyJoinTable").
>
> Build 164 I believe has an issue with quoting column names, where quoting
> making the columns case sensitive, so a "Pig_group_recid" doesn't work in
> place of the all caps one (which is probably what is defined in the
> database).
>

> Check out:http://groups.google.com/group/fluent-nhibernate/browse_thread/thread...
> for
> more details.

> > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com>

Gregory Kaidanov

unread,
Jan 24, 2010, 10:46:59 AM1/24/10
to Fluent NHibernate
Also ,
PropertyRef is not a part of HasManyToMany
and the Table name created by the join is not in the db at all , it's
created by FNH itself , and I have no control over it.

On Jan 24, 5:18 pm, Hudson Akridge <hudson.akri...@gmail.com> wrote:

> You need to do a .PropertyRef() if you're joining to the join table on a
> non-id. PropertyRef expects the propertyname, not the column name. To
> specify your join table, you use .Table("LegacyJoinTable").
>
> Build 164 I believe has an issue with quoting column names, where quoting
> making the columns case sensitive, so a "Pig_group_recid" doesn't work in
> place of the all caps one (which is probably what is defined in the
> database).
>

> Check out:http://groups.google.com/group/fluent-nhibernate/browse_thread/thread...
> for
> more details.

> > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages