473,559 Members | 2,982 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

some problems with ORM concept....what do you think?

For all the ORM i have searched around, I have always found two big problems:

1) To update or delete a set of records you must first bring it to memory.
If you are inside a loop and have to do it n times, then you have to query
this set n times as well. Would be nice if ORM could make it easier (in a
strongly type manner) to call a dynamic query to directly update/delete
records.

2) I have noticed all ORM work with collection as thei return datatype of a
query. Well, you cannot add, delete, replace, or reorder the elements in this
collection...th is restrict a lot the way you can work, specially if you are
iterating in a loop and have to make changes to the same table you are
iterating...

What are your opinions about it ?
Aug 19 '06 #1
12 2380
Sure you can do all of that with HQL in NHibernate.

J.

Bruce One wrote:
For all the ORM i have searched around, I have always found two big problems:

1) To update or delete a set of records you must first bring it to memory.
If you are inside a loop and have to do it n times, then you have to query
this set n times as well. Would be nice if ORM could make it easier (in a
strongly type manner) to call a dynamic query to directly update/delete
records.

2) I have noticed all ORM work with collection as thei return datatype of a
query. Well, you cannot add, delete, replace, or reorder the elements in this
collection...th is restrict a lot the way you can work, specially if you are
iterating in a loop and have to make changes to the same table you are
iterating...

What are your opinions about it ?
Aug 19 '06 #2
I may have misexposed what I really meant.
I meant all ORM do HAVE these 2 problems below...
Hibernate (which I have already studied) works exaclty this ways, that is,
it has to bring to memory all records it needs to update/delete, and, since
it works with collections, you just cant update/delete any member of this
collection in such a way the collection gets "lost"....

"Jimmy" wrote:
Sure you can do all of that with HQL in NHibernate.

J.

Bruce One wrote:
For all the ORM i have searched around, I have always found two big problems:

1) To update or delete a set of records you must first bring it to memory.
If you are inside a loop and have to do it n times, then you have to query
this set n times as well. Would be nice if ORM could make it easier (in a
strongly type manner) to call a dynamic query to directly update/delete
records.

2) I have noticed all ORM work with collection as thei return datatype of a
query. Well, you cannot add, delete, replace, or reorder the elements in this
collection...th is restrict a lot the way you can work, specially if you are
iterating in a loop and have to make changes to the same table you are
iterating...

What are your opinions about it ?

Aug 19 '06 #3
Bruce One <ra**@virtualso ftware.com.brwr ote:
I may have misexposed what I really meant.
I meant all ORM do HAVE these 2 problems below...
Hibernate (which I have already studied) works exaclty this ways, that is,
it has to bring to memory all records it needs to update/delete, and, since
it works with collections, you just cant update/delete any member of this
collection in such a way the collection gets "lost"....
No, Hibernate (at least the Java version) does *not* have to fetch
records in order to update/delete them.

See
http://www.hibernate.org/hib_docs/v3...tch.html#batch
-direct

aka http://tinyurl.com/4kpug

and scroll down to "DML-style operations".

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 20 '06 #4
Well the example you linked to me works exaclty the way I put there...look at
a piece of the code presented in the page you forward to me...

............... ...
............... ..
// TAKE A LOOK AT THE getNamedQuery method. IT RETURNS ALL RECORDS THAT WILL
BE UPDATED....

ScrollableResul ts customers = session.getName dQuery("GetCust omers")
.scroll(ScrollM ode.FORWARD_ONL Y);
while ( customers.next( ) ) {
Customer customer = (Customer) customers.get(0 );
customer.update Stuff(...);
session.update( customer);
}

tx.commit();
session.close() ;


"Jon Skeet [C# MVP]" wrote:
Bruce One <ra**@virtualso ftware.com.brwr ote:
I may have misexposed what I really meant.
I meant all ORM do HAVE these 2 problems below...
Hibernate (which I have already studied) works exaclty this ways, that is,
it has to bring to memory all records it needs to update/delete, and, since
it works with collections, you just cant update/delete any member of this
collection in such a way the collection gets "lost"....

No, Hibernate (at least the Java version) does *not* have to fetch
records in order to update/delete them.

See
http://www.hibernate.org/hib_docs/v3...tch.html#batch
-direct

aka http://tinyurl.com/4kpug

and scroll down to "DML-style operations".

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 20 '06 #5
Bruce One <ra**@virtualso ftware.com.brwr ote:
Well the example you linked to me works exaclty the way I put there...look at
a piece of the code presented in the page you forward to me...

............... ..
............... .
// TAKE A LOOK AT THE getNamedQuery method. IT RETURNS ALL RECORDS THAT WILL
BE UPDATED....

ScrollableResul ts customers = session.getName dQuery("GetCust omers")
.scroll(ScrollM ode.FORWARD_ONL Y);
while ( customers.next( ) ) {
Customer customer = (Customer) customers.get(0 );
customer.update Stuff(...);
session.update( customer);
}

tx.commit();
session.close() ;
Please read my post more carefully. You didn't scroll down to the "DML-
style operations" section as I suggested.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 20 '06 #6
Bruce One wrote:
For all the ORM i have searched around, I have always found two big
problems:

1) To update or delete a set of records you must first bring it to
memory. If you are inside a loop and have to do it n times, then you
have to query this set n times as well. Would be nice if ORM could
make it easier (in a strongly type manner) to call a dynamic query to
directly update/delete records.
Not all O/R mappers force that on you. Some, like LLBLGen Pro (which
I'm the lead developer of), offer the ability to update/delete entities
directly in the persistent storage.

The reason why O/R mappers don't offer these query capabilities often
is based on the fact that it would make their internal caches
completely void.
2) I have noticed all ORM work with collection as thei return
datatype of a query. Well, you cannot add, delete, replace, or
reorder the elements in this collection...th is restrict a lot the way
you can work, specially if you are iterating in a loop and have to
make changes to the same table you are iterating...
I'm not sure what your question is, but I don't recognize this
limitation in my work. Which 'ORM' frameworks are you talking about?

Frans
--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Aug 20 '06 #7
Frans,
You mean you would pass a raw sql to your update/delete method? Or is it
done using Dynamic Query? If so, how an Update command like below would be
called in your BusinessLogic, in such a way you can use all Strongly-Typed
fields?

Update Customers
Set CustomerName = "Bruce"
,CustomerAge = 30
WHERE CustomerID = 30
"Frans Bouma [C# MVP]" wrote:
Bruce One wrote:
For all the ORM i have searched around, I have always found two big
problems:

1) To update or delete a set of records you must first bring it to
memory. If you are inside a loop and have to do it n times, then you
have to query this set n times as well. Would be nice if ORM could
make it easier (in a strongly type manner) to call a dynamic query to
directly update/delete records.

Not all O/R mappers force that on you. Some, like LLBLGen Pro (which
I'm the lead developer of), offer the ability to update/delete entities
directly in the persistent storage.

The reason why O/R mappers don't offer these query capabilities often
is based on the fact that it would make their internal caches
completely void.
2) I have noticed all ORM work with collection as thei return
datatype of a query. Well, you cannot add, delete, replace, or
reorder the elements in this collection...th is restrict a lot the way
you can work, specially if you are iterating in a loop and have to
make changes to the same table you are iterating...

I'm not sure what your question is, but I don't recognize this
limitation in my work. Which 'ORM' frameworks are you talking about?

Frans
--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Aug 20 '06 #8
Jon, I saw it. But you must agree this is not Dynamic Query, it does not deal
with strongly-typed fields, its just raw sql, as the code extracted from the
Hibernate page (below)...

String hqlUpdate = "update Customer c set c.name = :newName where c.name =
:oldName";
"Jon Skeet [C# MVP]" wrote:
Bruce One <ra**@virtualso ftware.com.brwr ote:
Well the example you linked to me works exaclty the way I put there...look at
a piece of the code presented in the page you forward to me...

............... ..
............... .
// TAKE A LOOK AT THE getNamedQuery method. IT RETURNS ALL RECORDS THAT WILL
BE UPDATED....

ScrollableResul ts customers = session.getName dQuery("GetCust omers")
.scroll(ScrollM ode.FORWARD_ONL Y);
while ( customers.next( ) ) {
Customer customer = (Customer) customers.get(0 );
customer.update Stuff(...);
session.update( customer);
}

tx.commit();
session.close() ;

Please read my post more carefully. You didn't scroll down to the "DML-
style operations" section as I suggested.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 20 '06 #9
Bruce One <ra**@virtualso ftware.com.brwr ote:
Jon, I saw it. But you must agree this is not Dynamic Query, it does not deal
with strongly-typed fields, its just raw sql, as the code extracted from the
Hibernate page (below)...

String hqlUpdate = "update Customer c set c.name = :newName where c.name =
:oldName";
No, it's not just raw SQL. You can use the properties to perform a
path, eg

"delete Customer c where c.address.zipco de = ...."

What else would you want out of ORM when it comes to updating or
deleting?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 20 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1643
by: vivek | last post by:
Hi all, Here we are conducting a QIP program for teachers in other colleges. I am assigned the job of taking lectures in Python. Although there will be not much time (exactly speaking : 4 hours) for me to tell them each and everything in python, I am trying to cover as much as I can. Here are the areas which I am planning to cover : 1....
18
6497
by: gabriel | last post by:
greetings, I am currently working on a website where I need to print the Euro symbol and some "oe" like in "oeuvre". If I choose this : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > <html
10
1817
by: John | last post by:
Hi all... Either I'm doing really something really stupid - or maybe there is some bug somewhere (optimizing?). In a function I have: int x1, y1, x2, y2; float dR, dX, dY; dR = (state.cam1x - x1) - (state.cam2x - x2); dX = 0.5 * ((state.cam1x - x1) + (state.cam2x - x2));
2
1983
by: Vamshi | last post by:
I do have some problems. Can any one help me out? 1.Ordered squares. A 6-digit number STWXYZ is an ordered number if the diff between first 3 dig, STW and last three XYZ is 1. For example 123124 or 124123 are ordered num. A number is a square if it is equal to the product of one whole number mul by itself.An ordered square is both an ordered...
0
779
by: yxq | last post by:
Hello The resource code have some problems, Context Menu can show the selected file, but system can not open multi-files at one time, if select two or more txt files and right-click, click Open, system can not open the txt files. http://www.mvps.org/emorcillo/vb6/shell/shlext.msi
12
1672
by: johannblake | last post by:
First off, I am NOT a beginner. I have lots of experience developing professional web sites and am a professional software developer. Unfortunately I've been out of web site development for the past 2 years but would like to get back into it. What I need is some advice to get me up-to-date on what is the best (or one of the best) ways of...
1
1465
by: Wayne Shu | last post by:
Today when I read TC++PL(se) section 4.8 Enumerations, I get some problems. 1. In an enumeration, why the value of some enumerators can be the same, for instance: enum e1{a = 0, b = 0, c = 0}; we can't distinguish a, b and c by value, when they are used in switch statement, the compiler will complain that they have the same value. why not...
11
5561
by: jjkeeper | last post by:
Hi, I need to create an annual leave Database for the company. I admit I was a complete novice at this. But I got thrown the job and I have to do it. So here's what I get so far, but I got pretty much stuck for some days figuring out what to do. Sorry I can't think of a better title. I have a tblMainProfile table, which stores everything about...
0
1329
by: Chocolade | last post by:
Thorsten this is what i did dont forget im using also onmousewheel event. First in the constructor i did: trackBar1_radar_images = new TrackBar(); this.Controls.Add(trackBar1_radar_images); trackBar2_satellite_images = new TrackBar(); this.Controls.Add(trackBar2_satellite_images); DirectoryInfo dir1...
0
7836
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8061
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7915
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5455
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5172
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1165
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
872
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.