lazy-initialization

LazyInitializationException due to no session defined in “parent” application context in Hibernate 3 in a moduled Spring application using annotations

前提是你 提交于 2019-12-11 23:29:08
问题 I am fairly new to both Hibernate3 and Spring3, and I'm having an issue related to initializing lazy references of a hibernate object. I have a fully contained dao and service. The domain objects are created using hbm2java and a reverse engineering file. I have followed some best practices I have found using Annotations (@Transactional) on my service objects. (This guide was VERY helpful to me http://carinae.net/2009/11/layered-architecture-with-hibernate-and-spring-3/) The issue that I am

Spring batch late binding for stepExecutionContext not working

只愿长相守 提交于 2019-12-11 19:46:22
问题 I am using Spring batch application and want to use late binding for stepExecutionContext. I am facing issues in resolving my error. Following is my reader which has sql property using late binding: <bean id="itemReader_S4_JPolicy" class="com.aegonusa.etl.readers.JDBCItemReader" scope="step"> <property name="jobParameters" ref="jobParameters" /> <property name="dataSource" ref="readDataSource" /> <property name="rowMapper"> <bean class="com.aegonusa.etl.readers.ResultSetRowMapper" scope="step

Hibernate 5: db connections are still not released (idle in transaction) after lazy loading

寵の児 提交于 2019-12-11 10:57:53
问题 In Hibernate 5 there are still big troubles with releasing database connections after initialization of lazy collection. Database connections after lazy initialization of collection are kept in "idle in transaction". So if many users work at the same time, count of open connections is increasing critically. We use hibernate version 5.0.12 , java version 1.8.0_151 , jsf 2.3 , don't use Spring (ORM). There is reported issue for Hibernate version 3.2.7 - HHH-4808 - still opened. The last comment

Autofac optional/lazy dependencies

夙愿已清 提交于 2019-12-11 06:56:40
问题 If I put Lazy in constructor of my object, and X is not registered in container I got dependency resolution exception. Why am I getting this exception? I dislike it, because I cannot choose component at runtime. Example usecase: class Controller { public Controller(Lazy<A> a, Lazy<B> b) { /* (...) */ } Lazy<A> a; Lazy<B> b; public IActionResult Get(){ if(someConfig) return Json(a.Value.Execute()); else return Json(b.Value.Execute()); } } To do so I need to register both components A an B. My

Initialization order of values in objects: How to setup cyclic/recursive objects properly?

我们两清 提交于 2019-12-11 02:22:51
问题 The following code abstract class Table(val name: String) { val columns: List[Column] def getAliasColumns: String = { val reallyThere = columns.forall(c => c != null) println("Columns really there: " + reallyThere) if (reallyThere == false) { println(" columns " + columns) } columns.map(c => s"${c.table.name}.${c.name} as ${c.table.name}_${c.name}") .mkString(", ") } } class Column(val table: Table, val name: String, val foreignKey: Option[Column]) object Column { def apply(table: Table, name

Lazy lookup of a dictionary value using a stateless session

≯℡__Kan透↙ 提交于 2019-12-10 20:39:46
问题 In my app, I set up a ternary dictionary mapping so that for a given user, I can retrieve "settings" for each instance of an object that belongs to the user. That is, I have something like: public class User { public virtual IDictionary<Baz, BazSettings> BazSettings { get; set; } //... So whenever I have a Baz object, I can lookup the current user's baz settings via currentUser.BazSettings[baz] . I would like to be able to use a stateless session to do this, but I get a

Covariant use of generic Lazy class in C#

≯℡__Kan透↙ 提交于 2019-12-10 16:17:04
问题 Assuming that this applies: public class Cat : Animal { } and assuming that I have a method: public void Feed(Animal animal) { ... } And I can call it this way: var animal = new Cat(); Feed(animal); How can I get this working when Feed is refactored to only support Lazy<Animal> as parameter? I'd like to pass in my var lazyAnimal = new Lazy<Cat>(); somehow. This obviously doesnt work: var lazyAnimal = new Lazy<Cat>(); Feed(lazyAnimal); 回答1: Well, you won't be able to use it exactly as is.

Hibernate: will merge work with many-to-one object transtively?

你说的曾经没有我的故事 提交于 2019-12-10 11:24:41
问题 Hi I know that and tested before merge will reattach the object back to session preventing lazy initialization exception when object is no longer in session. a.) So I have a few question. If i payment --> customer (in a many-to-one unidirectional relationship) and I do Payment payment = Payment.class.cast(session.merge(oldPayment)); Will customer object also be reattach into session, or do I have to make another merge call for the customer. b.) What happen if the payment--> customer (many-to

Type inference when using lazy instantiation

折月煮酒 提交于 2019-12-10 09:34:03
问题 Why does type inference on Swift not work here when using lazy instantiation of a property? class GameView: UIView { private lazy var animator = UIDynamicAnimator(referenceView: self) ... } I get an error in relation to the use of self : Cannot convert value of type ‘(NSObject -> () -> GameView)’ to expected argument type UIView (Not sure whether the error is meaningful or not-- perhaps I'm not understanding it properly) ...However when it is explicitly typed, then there is no error: class

Are Swift constants lazy by default?

偶尔善良 提交于 2019-12-10 09:26:10
问题 Something I still not quite understand about Swift ... let's say I want a property that instantiates a class in a base class used for several sub classes, e.g. ... let horse = Horse(); Is horse instantiated right after app/class initialisation or when the property is accessed for the first time? On the other hand using lazy var guarantees that the property is only instantiated the first time it is accessed ... lazy var horse = Horse() But then horse is not a constant. So in this case if I