c*t
2 楼
Can any nHibernate expert let me know what's wrong with the following? I
alwasy got Acccount.ListAttr as null; when do "foreach(var a in Account.
ListAttr)" I got invalid cast error: can't cast ISet to IList..
I have Account.hbm.xml as follows:
...
..
and Account.cs has:
public virtual ISet ListAttr {get; set; }
..
Also have SomeOtherClass.hbm.xml:
...
select Col1, Col2 from SomeTable where attr=?
and SomeOtherClass.cs
public virtual String Col1 {get; set; }
public virtual String Col2 {get; set; }
public virtual int SomeId {get; set; }
..
alwasy got Acccount.ListAttr as null; when do "foreach(var a in Account.
ListAttr)" I got invalid cast error: can't cast ISet to IList..
I have Account.hbm.xml as follows:
...
..
and Account.cs has:
public virtual ISet
..
Also have SomeOtherClass.hbm.xml:
...
select Col1, Col2 from SomeTable where attr=?
and SomeOtherClass.cs
public virtual String Col1 {get; set; }
public virtual String Col2 {get; set; }
public virtual int SomeId {get; set; }
..
P*P
3 楼
在写一个class,要return三个参数,我现在是把三个参数放到map里,然后return map.不
知道这样做好不好?还是我应该把三个参数做成object,然后return那个object?
知道这样做好不好?还是我应该把三个参数做成object,然后return那个object?
c*t
4 楼
其实就是根据Account table中的一个field去query一组tables得到一组数据: ISet<
CustomClass> ListAttr。
CustomClass> ListAttr。
s*o
6 楼
if you are using .NET 4, then there are two ISet available.
One is from System.Collections.Generic, and the other is from Iesi.
Collections.Generic. Maybe there is a type mismatch here?
One is from System.Collections.Generic, and the other is from Iesi.
Collections.Generic. Maybe there is a type mismatch here?
c*t
8 楼
I use .NET 3.5.
c*t
10 楼
using profile, I figured what went wrong. I have Account.hbm.xml as
...
The issue was nHibernate always passes in "Account_Id" for my sql-query...
it's not SomeId.
...
The issue was nHibernate always passes in "Account_Id" for my sql-query...
it's not SomeId.
c*t
12 楼
It's mapping issue:
WARN:
System.IndexOutOfRangeException: Unable to find specified column in result
set
at Oracle.DataAccess.Client.OracleDataReader.GetOrdinal(String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[]
names, ISessionImplementor session, Object owner)
at NHibernate.Type.ManyToOneType.Hydrate(IDataReader rs, String[] names,
ISessionImplementor session, Object owner)
at NHibernate.Persister.Entity.AbstractEntityPersister.Hydrate(
IDataReader rs, Object id, Object obj, ILoadable rootLoadable, String[][]
suffixedPropertyColumns, Boolean allProperties, ISessionImplementor session)
at NHibernate.Loader.Loader.LoadFromResultSet(IDataReader rs, Int32 i,
Object obj, String instanceClass, EntityKey key, LockMode lockMode,
ILoadable rootPersister, ISessionImplementor session)
at NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i,
ILoadable persister, EntityKey key, LockMode lockMode, EntityKey
optionalObjectKey, Object optionalObject, IList hydratedObjects,
ISessionImplementor session)
at NHibernate.Loader.Loader.GetRow(IDataReader rs, ILoadable[] persisters
, EntityKey[] keys, Object optionalObject, EntityKey optionalObjectKey,
LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet,
ISessionImplementor session, QueryParameters queryParameters, LockMode[]
lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey
[] keys, Boolean returnProxies)
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.DoList(ISessionImplementor session,
QueryParameters queryParameters)
WARN:
System.IndexOutOfRangeException: Unable to find specified column in result
set
at Oracle.DataAccess.Client.OracleDataReader.GetOrdinal(String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[]
names, ISessionImplementor session, Object owner)
at NHibernate.Type.ManyToOneType.Hydrate(IDataReader rs, String[] names,
ISessionImplementor session, Object owner)
at NHibernate.Persister.Entity.AbstractEntityPersister.Hydrate(
IDataReader rs, Object id, Object obj, ILoadable rootLoadable, String[][]
suffixedPropertyColumns, Boolean allProperties, ISessionImplementor session)
at NHibernate.Loader.Loader.LoadFromResultSet(IDataReader rs, Int32 i,
Object obj, String instanceClass, EntityKey key, LockMode lockMode,
ILoadable rootPersister, ISessionImplementor session)
at NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i,
ILoadable persister, EntityKey key, LockMode lockMode, EntityKey
optionalObjectKey, Object optionalObject, IList hydratedObjects,
ISessionImplementor session)
at NHibernate.Loader.Loader.GetRow(IDataReader rs, ILoadable[] persisters
, EntityKey[] keys, Object optionalObject, EntityKey optionalObjectKey,
LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet,
ISessionImplementor session, QueryParameters queryParameters, LockMode[]
lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey
[] keys, Boolean returnProxies)
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.DoList(ISessionImplementor session,
QueryParameters queryParameters)
c*g
17 楼
store them into a vector and return it.
b*y
23 楼
object is better, it is easier to see what's returned.
k*r
24 楼
maps has poorer memory efficiency. java is already bad in terms of memory usage. Don't
make it worse :)
make it worse :)
n*8
26 楼
sounds a method that return 3 types of parameters. Why do you not use 3
public unique class variables that you can access from anywhere?
public unique class variables that you can access from anywhere?
t*e
27 楼
Thread safety will be an issue if he follows your suggestion.
The question is about static data typing (a data object) or dynamic data
typing (a Map, or List, or Collection). Static typing is always preferred
unless the data types may evolve in the future upon business requirements.
【在 n******8 的大作中提到】
: sounds a method that return 3 types of parameters. Why do you not use 3
: public unique class variables that you can access from anywhere?
m*t
28 楼
I don't know which part is scarier - "public" or "class".
I do like "unique" though. At least we are not going to
try and pad 3 parameters into one single string.
【在 n******8 的大作中提到】
: sounds a method that return 3 types of parameters. Why do you not use 3
: public unique class variables that you can access from anywhere?
相关阅读
JBoss 4.0.4 is slow down in every 20 days牛人能不能给通俗地解释一下CGI?请问公司里用Java主要干啥?Java如何实现自动消失的消息框?Oracle收购Sun后 最新公布的产品策略,怀念SUNAlgorithms in Java 书的答案这里友人用Gradle吗?Java Concurrency in Practise, 哪里有?please recommend a free profiler问个Charting的问题把EXT GWT里面的UI拿来做非开源的开发,合法性到底如何新手求问:学JavaWeb和J2EE有什么好教材?谁来帮忙推荐一本学习Maven的书how to solve the problem: the members change by each other .Recommend a Book about Algorithm? (转载)BruceEckel的BetterJava哪有下载的?C language的functoin-based reuse的问题(概念级的)eclipse how to remember a code location and jump back?急问: 在java中用软件包Colt 可以做 linear Regression吗?use the same class name in its declare