Re: Thoughts from ADO

Noel Grandin <[email protected]> Fri, 26 Nov 2010 14:00:52 +0200
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
--------------090908050105060103000909
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-Disposition: inline


Maybe this is one of those places where SimpleORM should provide a "pre-commit" hook that you could override to
implement custom stuff like this.

Or you could create your own sub-class of SSession and override the commit() method, and do your validation there.

-- Noel.

Franck Routier wrote:
>  
>
> Hi,
>
> Le vendredi 26 novembre 2010 à 10:33 +0200, Noel Grandin a écrit :
>
> > I think there are some things you are just going to have to handle at
> > a higher level, and this is one of them.
>
> Yes, I agree we want to keep Simpleorm simple... but...
> That's what I do right now; that is in my DAO layer, I have a method
> checkCustomConstraints that get called before a dataset is persisted.
>
> My problem is that a dataset can have every kind of records. So I must
> make sure custom constraints are called for each record type in the
> dataset... (before Sorm3, I was handling lists of records of the same
> type, so it was must easier).
>
> > I've seen frameworks where this is possible, but the downside is that
> > performance becomes very non-obvious, because the framework has to
> > query the database in order to perform cross-record validation.
>
> > On the other hand, you could always override doValidateRecord() and do
> > your extra validation there?
> >
> Well, doing it in doValidateRecord can be tricky, as it is called while
> the session has begun (on flush). So you'll have to get the the current
> thread's session and use queryNoFlush to get extra records from
> database, then check against still unflushed records in the dataset...
> Well, I could experiment with it...
>
> ...
>
> Franck
>
> 

Disclaimer: http://www.peralex.com/disclaimer.html



--------------090908050105060103000909
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit





<head>

<style type="text/css">
<!--

/* start of attachment style */
       .ygrp-photo-title{
         clear: both;
         font-size: smaller;
         height: 15px;
         overflow: hidden;
         text-align: center;
         width: 75px;
       }
       div.ygrp-photo{
         background-position: center;
         background-repeat: no-repeat;
         background-color: white;
         border: 1px solid black;
         height: 62px;
         width: 62px;
       }

       div.photo-title 
         a,
         div.photo-title a:active,
         div.photo-title a:hover,
         div.photo-title a:visited {
           text-decoration: none; 
       }

       div.attach-table div.attach-row {
         clear: both;
       }

       div.attach-table div.attach-row div {
         float: left;
         /* margin: 2px;*/
       }

       p {
         clear: both;
         padding: 15px 0 3px 0;
	 overflow: hidden;
       }

       div.ygrp-file {
         width: 30px;
         valign: middle;
       }
       div.attach-table div.attach-row div div a {
         text-decoration: none;
       }

       div.attach-table div.attach-row div div span {
         font-weight: normal;
       }

       div.ygrp-file-title {
         font-weight: bold;
       }
 /* end of attachment style */
        -->
        </style>
        </head>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">





    <font face="Tahoma"><br>
      Maybe this is one of those places where SimpleORM should provide a
      "pre-commit</font>" hook that you could override to implement
    custom stuff like this.<br>
    <br>
    Or you could create your own sub-class of SSession and override the
    commit() method, and do your validation there.<br>
    <br>
    -- Noel.<br>
    <br>
    Franck Routier wrote:
    <blockquote cite="mid:1290762051.21508.18.camel@franck-laptop"
      type="cite">
      <span style="display: none;"> </span>
      
          <div id="ygrp-text">
            <p>Hi,<br>
              <br>
              Le vendredi 26 novembre 2010 à 10:33 +0200, Noel Grandin a
              écrit :<br>
              <br>
              &gt; I think there are some things you are just going to
              have to handle at<br>
              &gt; a higher level, and this is one of them. <br>
              <br>
              Yes, I agree we want to keep Simpleorm simple... but...<br>
              That's what I do right now; that is in my DAO layer, I
              have a method<br>
              checkCustomConstraints that get called before a dataset is
              persisted.<br>
              <br>
              My problem is that a dataset can have every kind of
              records. So I must<br>
              make sure custom constraints are called for each record
              type in the<br>
              dataset... (before Sorm3, I was handling lists of records
              of the same<br>
              type, so it was must easier).<br>
              <br>
              &gt; I've seen frameworks where this is possible, but the
              downside is that<br>
              &gt; performance becomes very non-obvious, because the
              framework has to<br>
              &gt; query the database in order to perform cross-record
              validation.<br>
              <br>
              &gt; On the other hand, you could always override
              doValidateRecord() and do<br>
              &gt; your extra validation there?<br>
              &gt; <br>
              Well, doing it in doValidateRecord can be tricky, as it is
              called while<br>
              the session has begun (on flush). So you'll have to get
              the the current<br>
              thread's session and use queryNoFlush to get extra records
              from<br>
              database, then check against still unflushed records in
              the dataset...<br>
              Well, I could experiment with it...<br>
              <br>
              ...<br>
              <br>
              Franck<br>
              <br>
            </p>
          </div>
          
      
      <!-- end group email -->
    </blockquote>
  <br><br><br><hr><font size="-2" color=808080>Disclaimer: <a href="http://www.peralex.com/disclaimer.html">http://www.peralex.com/disclaimer.html</a><br><br>





<!-- |**|begin egp html banner|**| -->

<br>

    
    
<br>

<!-- |**|end egp html banner|**| -->


<div width="1" style="color: white; clear: both;"/>__._,_.___</div>

<!-- Start Recommendations -->
<!-- End Recommendations -->



<!-- |**|begin egp html banner|**| -->

  <img src="http://geo.yahoo.com/serv?s=97476590/grpId=7360226/grpspId=1705006905/msgId=1994/stime=1290772876" width="1" height="1"> <br>

<!-- |**|end egp html banner|**| -->

    
<!-- |**|begin egp html banner|**| -->

<br>
      <div style="font-family: verdana; font-size: 77%; border-top: 1px solid #666; padding: 5px 0;" >
      Your email settings: Individual Email|Traditional <br>
      <a href="http://groups.yahoo.com/group/SimpleORM/join;_ylc=X3oDMTJmMjhhMHQ3BF9TAzk3NDc2NTkwBGdycElkAzczNjAyMjYEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNmdHIEc2xrA3N0bmdzBHN0aW1lAzEyOTA3NzI4NzY-">Change settings via the Web</a> (Yahoo! ID required) <br>
      Change settings via email: <a href="mailto:[email protected]?subject=Email Delivery: Digest">Switch delivery to Daily Digest</a> | <a href = "mailto:[email protected]?subject=Change Delivery Format: Fully Featured">Switch to Fully Featured</a> <br>
           <a href="http://groups.yahoo.com/group/SimpleORM;_ylc=X3oDMTJkcXJqanJnBF9TAzk3NDc2NTkwBGdycElkAzczNjAyMjYEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNmdHIEc2xrA2hwZgRzdGltZQMxMjkwNzcyODc2">
        Visit Your Group 
      </a> |
      <a href="http://docs.yahoo.com/info/terms/">
        Yahoo! Groups Terms of Use
      </a> |
      <a href="mailto:[email protected]?subject=Unsubscribe">
       Unsubscribe 
      </a> 
 <br>
    </div>
  <br>

<!-- |**|end egp html banner|**| -->


<div style="color: white; clear: both;"/>__,_._,___</div>
</body>
</html>

--------------090908050105060103000909--