lazy-loading

Trying to confirm lazy loading is working

旧街凉风 提交于 2019-12-10 22:24:04
问题 I am learning hibernate and i am using the debugger to understand how hibernate fetches objects. I have enabled lazy loading in my XML and i use create a query to get an object. This object has a Set associated with it. When i look at the variable values in my debugger it seems to be completely loading the object graph, ie not lazily fetching the set and its properties. I can think of several reasons why this might be the case. 1) something is wrong with my xml / config and i have eager

On-demand eager loading

烈酒焚心 提交于 2019-12-10 21:49:17
问题 I make a query: String query = "SELECT DISTINCT a FROM A a FETCH ALL PROPERTIES " + "JOIN a.Bs AS b " + "JOIN b.Cs AS c WHERE c = :c"; Query q = DAO.getSession().createQuery(query); q.setParameter("c", c); return q.list(); Even though I've said FETCH ALL PROPERTIES on a, when I access all the collections that A has, they still need to be loaded, thus aren't eagerly loaded. They have been defined as lazy loading, and that is the default behaviour I want, but this is the exception: I would like

NHibernate: many-to-one and lazy

纵饮孤独 提交于 2019-12-10 19:24:01
问题 There is something regarding NHibernate 1.2 (webapp C# aspnet 3.5) and lazy loading that I don't understand and I can't find some clear answer: does many-to-one support lazy loading? Let's say we have some Person object and a Squeletton object. Both objects are big with many properties. A Person has one and only one Squeletton : myPerson.Squelleton. Mapping of Person : <many-to-one class='Squeletton' name='Squeletton' column='id_squeletton' lazy='proxy' /> I don't want the Squeletton property

Hibernate Lazy Loading with @LazyToOne(LazyToOneOption.NO_PROXY)

谁都会走 提交于 2019-12-10 18:26:19
问题 I have an app running Hibernate 4.2.21 on JBoss AS 7.2 We currently have a few @OneToOne relationships which, due to known limitations of lazy loading, will alway fetch eagerly on the inverse side. In order to enable Lazy loading for inverse relationships I am trying to enable build-time bytecode instrumentation. Here's what I've done so far... 1) Activate instrumentation using maven-antrun-plugin (I tried the hibernate-enhance-maven-plugin and couldn't get it working but thats for another

Lazily Reading a File in D

拈花ヽ惹草 提交于 2019-12-10 18:03:29
问题 I'm writing a directory tree scanning function in D that tries to combine tools such as grep and file and conditionally grep for things in a file only if it's not matching a set of magic bytes indicating filetypes such as ELF, images, etc. What is the best approach to making such an exclusion logic run as fast as possible with regards to minimizing file io? I typically don't want to read in the whole file if I only need to read some magic bytes in the beginning. However to make the code more

How do I manually open a hibernate session?

你。 提交于 2019-12-10 17:19:06
问题 I have a rather large project involving spring and hibernate. Right now, I'm backing certain objects out of hibernate and into memory, and I've hit a sort of snag. I have the following setup. Class A contains a number of primitives and a class B. B contains primitives and a class C, which was previously lazy-loaded . Now I have this Service call 1: 1.) create object of class A 2.) get object of class B 3.) set B in A 4.) add A to memory Service call 2: 1.) get A from memory 2.) get B from A 3

Which Hibernate FetchMode will cause collections to be lazy-loaded?

谁说胖子不能爱 提交于 2019-12-10 17:18:54
问题 I asked a this question on the Hibernate forums, but did not get a full response, so I thought I'd repost it here. Here's the original question thread: http://forum.hibernate.org/viewtopic.php?f=1&t=1008243&p=2438963#p2438963 In a nutshell, I have a custom HQL query that joins together two completely unrelated tables, and I'm trying to prevent the "O(N+1) selects" problem by disabling the loading of associated collections that exist in my Hibernate-mapped POJOs. Apparently, I can use

iOS: How to stop a background thread from updating UI in the main thread?

二次信任 提交于 2019-12-10 16:29:21
问题 I implement a UITableView of UIImageView cells, each of which periodically refreshes itself every 5 seconds via NSTimer. Each image is loaded from a server in the background thread, and from that background thread I also update the UI, displaying the new image, by calling performSelectorOnMainThread . So far so good. Currently I face a problem when I don't wait until an image is loaded at a current cell and I scroll down quickly to a new cell. That new cell, however, displays an image of a

Hibernate - One table with multiple entities?

我怕爱的太早我们不能终老 提交于 2019-12-10 15:46:27
问题 I have a Picture : public class Picture implements java.io.Serializable { private byte[] picEncoded; private String Name; //etc Is it's possible to move byte[] to another class without creating physically separated table in db? Do i need to use some inheritance strategy? edit Blob in separate entity: pojo : public class PictureBlob implements java.io.Serializable { private Integer pictureBlobId; private byte[] blob; hbm: : <class name="PictureBlob" table="PICTURE"> <id name="pictureBlobId"

nHibernate Collection Count

家住魔仙堡 提交于 2019-12-10 15:11:07
问题 I have the following model which I have created and mapped with nHibernate. Using lazy loading so I don't need to get the Vehicles for the Dealer at the start. Public class Dealer { public virtual string Name { get;set;} public virtual IList<Vehicles> Vehicles { get;set;} } Now let's assume the Dealer has thousands of vehicles. If I do Dealer.Vehicles.Count then NH will select and pull all the data. What is the best way to simply get a count? Is there any way in which I can get a count with