开发者

Querying a Temporary Table in NHibernate

开发者 https://www.devze.com 2023-03-18 09:51 出处:网络
I have a process which generates a result set for me and stores it in a temporary table.I have the name of the temporary table.I am trying to find a way, using NHibernate, to create a DetachedCriteria

I have a process which generates a result set for me and stores it in a temporary table. I have the name of the temporary table. I am trying to find a way, using NHibernate, to create a DetachedCriteria against the temporary table. To put it another way, I have a table [Book] which has a column, [BookId]. I have a temporary table [TempTableName], which has a column [TempId]. I want to create a DetachedCriteria for the [Book] table, wherein all the [Book] s with [BookId] in [Te开发者_开发技巧mpTableName] .[TempId] are returned. Is there any way to do this, preferably with the Criteria API? Especially given that the name of the temp table itself may vary from run to run?


Hm, I'd say it should be possible and maybe even without extending/changing Hibernate/NHibernate.

You could introduce a class that maps the temporary table, but that table would only exist (sometimes) at runtime, so Hibernate's validation would probably complain at startup, unless you disable it, which is possible as far as i recall.

Have you tried mapping a class to a temporary table? The naming scheme of the temporary tables might be problematic in query generation. They will probably be specific to your RDBMS.

I guess that all these things can be solved by extending some Hibernate classes, but I have not tried.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号