Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

Hibernate foreign key relation - list() makes unnecessary sql queries - setMaxResults ignored -


first of all, first time use hibernate questions might seem naive.

i have 2 tables, dsjobs , dsevents. events has foreign key relationship on dsjobs table (eid column in dsjobs table corresponds id column of dsevents table).

i have creted mapping anotations, care unilateral relation, have 'dsevents' property in dsjobs table annotated @manytoone:

@entity @table(name="dsjobs") public class dsjobs  implements java.io.serializable {  ...       private dsevents dsevents;    ...       @id     @column(name="jid", unique=true, nullable=false)     public long getjid() {         return this.jid;     }      public void setjid(long jid) {         this.jid = jid;     }  @manytoone     @joincolumn(name="eid")      public dsevents getdsevents() {         return this.dsevents;     }      public void setdsevents(dsevents dsevents) {         this.dsevents = dsevents;     } .... } 

i want retrieve list of jobs records databse , restricte them setfirstresult , setmaxresults. call make:

return (arraylist<dsjobs>) this.sessionfactory.getcurrentsession().createquery("from dsjobs log").setfirstresult(start).setmaxresults(rows).list(); 

this code returns arraylist of dsjobs object , inside every dsjobs object there dsevents object, correctly instantiated.

my issues two:

  1. when see hql executed there unnecesery select calls database, 1 every dsjobs record. each dsjobs record, there select in dsevents coresponding event, event id. unacceptable performance, since simple jdbc can data need inner join select stament. doing wrong, please let me know , if know how should proceed.

  2. the setfirstresult , setmaxresults seem completeley ignored hibernate, records database. how can fix that?

i appreciate help.

thank in advance.

when see hql executed there unnecesery select calls database, 1 every dsjobs record.

yes, dreaded n+1 select problem. happens when enforce ri constraint on relationship (one-to-ones, example, or unique constraints). mapping you're showing doesn't appear have these problems, makes me think you're not showing actual mapping causing trouble. please post actual code, not generalized, abbreviated version of it.

the setfirstresult , setmaxresults seem completeley ignored hibernate, records database. how can fix that?

this code fine. means you're not showing actual code that's causing trouble.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -