SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 54

Hybrid View

  1. #1
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A Metastorage real life example

    Guys, i'm trying to find any Metastorage in action demos but can't see any real world examples of painless mapping of some existing rich domain model into relational database using it. By rich model i mean different kinds of relationships between objects: simple and bidirectional association, aggregation, etc. Anything similar to CaveatEmptor demo app written with Hibernate could be very helpful.

    Yes, I'm aware of Metastorage tutorial but i find it a bit strange. The author of this tutorial starts coding some XML stuff in the first place where i'd like to see designing model first.

  2. #2
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pachanga
    Guys, i'm trying to find any Metastorage in action demos but can't see any real world examples of painless mapping of some existing rich domain model into relational database using it. By rich model i mean different kinds of relationships between objects: simple and bidirectional association, aggregation, etc.
    Metastorage supports 1-1 , 1-many, many-many relationships between objects of different classes (or even the same class).

    1-1 is implemented defining a reference variable, i.e. a variable in a class that contains a reference to an object of another class.

    1-many is implemented via collections. Collections are abstract definitions that say that each object of a class contains a collection of objects of another class.

    many-many relationships are implemented via reciprocal collections. This means that each object of class A has a collection of objects of class B, and each object of class be has a collection of objects of class A.

    Quote Originally Posted by pachanga
    Anything similar to CaveatEmptor demo app written with Hibernate could be very helpful.
    I do not have complete working example that I can publish. However, I can try to provide a similar example to CaveatEmptor soon.

    Meanwhile, you can just try to build the example CMS component provided with Metastorage distribution. It generates classes that implement all types of relationships that I described above.

    It also generates a create article object form class named createarticle.form which basically demonstrates how it uses the Metastorage generated code to implement a class for generating a Web form to create new objects of the CMS article DAO class.


    Quote Originally Posted by pachanga
    Yes, I'm aware of Metastorage tutorial but i find it a bit strange. The author of this tutorial starts coding some XML stuff in the first place where i'd like to see designing model first.
    Well that XML stuff is your project model design. A project is defined by components. A component is package made by a set of related classes.

    In the Metastorage component definition you describe you data object classes in that XML format described in the tutorial. The <class> definition sections include class variables (scalar or references), validation rules, collections (for 1-many or many-many relationships).

    Then you would need to add some function definitions to make the classes do what your applications needs, but that is more than just the data design model.

    If you want to see a UML diagram of the classes of a given component, you can tell Metastorage to generate a UML diagram using GraphViz. Here is a UML class diagram of the example CMS project.

    You could also use an UML editor program and save the a project with a class diagram to the XMI format. There is an experimental XMI-Metastorage XSL stylesheet to let you convert UML projects in XMI to Metastorage component format.

    Anyway, I understand that for somebody that never used a project like Metastorage before, some concepts may seem too abstract.

    Just let me know if these explanations helped you to get started or it is still confusing. Your feedback may help me figure what explanations need to be improved in Metastorage tutorial, reference manual, FAQ and troubleshooting guides.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  3. #3
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the quick answer, still i have questions.

    I don't need all that web forms and UML auto builder stuff, all i need is to map my buisness domain to relational db. Thus i'd like to know how much unobtrusive and transparent is Metastorage for my domain model. For some reason i have a feeling that Metastorage tries to build model for me not simply map it. This is what i want to avoid at all costs.

  4. #4
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pachanga
    Thanks for the quick answer, still i have questions.

    I don't need all that web forms and UML auto builder stuff,
    Right, I do not use that much yet. Forms will be great but for now Metastorage only generates new object forms. There is not yet support for editing/deleting objects from generated form classes, despite Metastorage generates DAO classes with all the necessary functionality. For Web form UI, currently I use and recommend to create form handling classes by hand with this forms generation class.

    UML diagram generation is more for documentation purposes.

    BTW, for a real world example of application of Metastorage generated code, you may look at the PHP Classes site forums system. The source code is not available but from the outside you can already see that it is used to create new forum threads, messages, and user subscriptions.

    The Metastorage report class generation support was used to generate thread listings, RSS feeds and even generate SQL to hand over to an external system that delivers forum update notifications by e-mail to users subscribed to the forum threads.

    If that helps, I can show you the forum component definition in Metastorage format.


    Quote Originally Posted by pachanga
    all i need is to map my buisness domain to relational db. Thus i'd like to know how much unobtrusive and transparent is Metastorage for my domain model. For some reason i have a feeling that Metastorage tries to build model for me not simply map it. This is what i want to avoid at all costs.
    I am not sure if I understand you. Metastorage generates data object classes from a model definition. Metastorage also generates schema installation classes but if you already have an installed database schema, you will not need to use that part unless you would like to change your classes or add more to your model.

    Maybe it would be better if you show me a sample class of your model either in PHP or an UML class diagram drawing, then I could tell you how the class definition class would look like in Metastorage component format.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  5. #5
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I may or may not be out of line on this comment, but the impression that I've now been left with is that Mlemos - would - expects us to build our application frameworks, etc around Metastorage, rather than the other way round.

    It just doesn't work, not that I'm saying that there is anything bad about Metastorage - there isn't, but it's not to everyones tastes, which I've tried to explain in another thread yersterday.

    I note my points were ignored

  6. #6
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just tell me one simple thing - does this component format describe model mapping(like in Hibernate) or it's used for generating model for me? If the latter i don't think Metastorage is the right choice...

    Say, i have a fully tested business model with its own rules, validations, etc. Now i want to throw persistence in the mix. How would i map it with Metastorage? Can i be sure that Metastorage will use exactly my model for mapping and won't mangle it in any way?

  7. #7
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pachanga
    Just tell me one simple thing - does this component format describe model mapping(like in Hibernate) or it's used for generating model for me? If the latter i don't think Metastorage is the right choice...

    Say, i have a fully tested business model with its own rules, validations, etc. Now i want to throw persistence in the mix. How would i map it with Metastorage? Can i be sure that Metastorage will use exactly my model for mapping and won't mangle it in any way?
    Metastorage uses a different approach than Hibernate. From what I could see Metastorage approach seemed less complicated (less development steps), more efficient (uses less code and less memory at runtime).

    Trying to use your terminology, Metastorage lets you design your classes' model in that XML format. You can add functions to the class in the same definition section. Such functions can perform whatever operations your application needs to manipulate the objects.

    You can add several types of functions, like persist, delete, validate, etc... For those Metastorage generates the necessary code. Usually you do not need more than these types of functions, but now you can also add custom types of functions and variables to perform special types of operations that are not generated by Metastorage. The definition of custom functions also goes in the class definition in XML. Custom functions are available but not yet in a public release. Such release should happen in the next 2 weeks.

    So, giving you a more direct answer, Metastorage generates code that bundles the whole model and persistence functionality in the same class. I think it can address your requirement of being able to customize your model class with your own rules and validations.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  8. #8
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mlemos
    Metastorage uses a different approach than Hibernate. From what I could see Metastorage approach seemed less complicated (less development steps), more efficient (uses less code and less memory at runtime).
    Frankly speaking i don't find Hibernate difficult at all, on the contrary it provides one of the most logical ways to map existing domain model into db without touching it. And of course we should not be comparing effectiveness of these two absolutely different tools running on totally different platforms. Please let's not make it a PHP vs Java thread.

    Trying to use your terminology, Metastorage lets you design your classes' model in that XML format. You can add functions to the class in the same definition section. Such functions can perform whatever operations your application needs to manipulate the objects.
    But i don't need that. I have my own nicely crafted and tested model and i don't want to autogenerate it. Why would i need to "add functions to the class" with some alien code generator if i can do it myself with a pair of hands and editor ???

    So, giving you a more direct answer, Metastorage generates code that bundles the whole model and persistence functionality in the same class. I think it can address your requirement of being able to customize your model class with your own rules and validations.
    It seems that Metastorage generates some sort of ActiveRecord, right? If yes, it's not the tool i need and it's simply not valid to compare Metastorage and Hibernate then.

    Let me guess, this is the way Metastorage actually works as i see it:
    1) A developer must hack some XML which actually describes business model and mapping model at the same time
    2) Metastorage generates domain model with persistence hooks for developer using mentioned above XML.
    3) If a developer wants to change something in the domain model he must edit XML and restart generation process. He can't edit generated code because it may be overwritten during next code generation. Yikes
    4) Developer must program his domain model using XML, i think this is what Metal is for.

    If all above is true it's simply unacceptable for me, i don't want to learn Metal and want my model to be controlled only by me.
    Last edited by pachanga; Oct 8, 2005 at 05:04.

  9. #9
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pachanga
    Frankly speaking i don't find Hibernate difficult at all, on the contrary it provides one of the most logical ways to map existing domain model into db without touching it. And of course we should not be comparing effectiveness of these two absolutely different tools running on totally different platforms. Please let's not make it a PHP vs Java thread.
    If you read me again, you may notice that I did not say whether Hibernate is difficult. If it is difficult, it is a problem of those that use it. What I said is that Metastorage approach seemed less complicated (less development steps), more efficient (uses less code and less memory at runtime). Once you try Metastorage in practice you will understand better what I am telling you.

    Quote Originally Posted by pachanga
    But i don't need that. I have my own nicely crafted and tested model and i don't want to autogenerate it. Why would i need to "add functions to the class" with some alien code generator if i can do it myself with a pair of hands and editor ???
    What I am trying to tell you is that with Metastorage it will still be you crafting your model and adding your customizations to the way persistence is done.

    What happens is that adding persistence support may mean adding many types of functionality to your model . Metastorage is Aspect Oriented. This means that depending on the purposes of you project, you can add and remove support to implement just the aspects your project needs.

    If you just need to store your objects, you just add a function of type persist. If you also need to delete objects, you also add a function of type delete.

    Now, lets say you need that one variable or a combination of variables of your class need to be unique to satisfy your project business rules. Metastorage lets you define a validation rule that verifies the uniqueness of the values of those object variables among all your objects. To verify this validation rule, you can just add a function of type validate to your class definition, and Metastorage generates the necessary code to implement it.

    If you need to implement custom validation rules, you add a function of type custom and write the necessary PHP code for it (which I understand you already did).

    Now, why do you need to tell which functions to add functions to your classes? Because Metastorage generates classes that are not bloated, as they only have the code that you need. Therefore, you need to tell what you want. This is what is called the JE WIN approach: Just Exactly What I Need.


    Quote Originally Posted by pachanga
    Let me guess, this is the way Metastorage actually works as i see it:
    1) A developer must hack some XML which actually describes business model and mapping model at the same time
    2) Metastorage generates domain model with persistence hooks for developer.
    No, Metastorage generates classes that can persist their object following the rules that you define. The generated code is self-contained. This means that the generated classes already know how to persist their objects and does not need externally defined persistence code.


    Quote Originally Posted by pachanga
    3) If a developer wants to change something in the domain model he must edit XML and restart generation process.
    You also need to edit the XML for the mappings with Hibernate. There are no miracles! The classes must know how to persist their objects.

    Here is one example of Hibernate mapping XML definition and a Metastorage class XML definition so you can reach your own conclusions about what is more complex.

    The difference is that the Metastorage code is ready to persist their objects without any further cost of memory and CPU at runtime.

    I do not use Hibernate, maybe somebody that tried it could comment better on this, but from what I understood from Hibernate it needs to process the mappings definitions at runtime to figure how to persist the objects.


    Quote Originally Posted by pachanga
    He can't edit generated code because it may be overwritten during next code generation. Yikes
    The beauty of Metastorage is that you do not need to edit the generated code ever, as you already told it to generate classes with all the code you need, including any custom PHP functions that you want.


    Quote Originally Posted by pachanga
    4) Developer must program his domain model using XML, i think this is what Metal is for.

    If all above is true it's simply unacceptable for me, i don't want to learn Metal and want my model to be controlled only by me.
    No, that is a misconception that was spread by Propel author. I wish Open Source authors did not need to mislead to attract users to their packages.

    If you read Metastorage FAQ, you can see that you never need to know or use MetaL to use Metastorage:

    Do I have to know the MetaL language to use Metastorage?

    No. MetaL is just a means to generate code in a target language of your choice. The generated code can be used in your applications like any other code of the programming language that you use.

    Metastorage uses a XML based format named CPML to define the components that it generates, but this format has nothing to do with normal programs in the MetaL language.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  10. #10
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You also need to edit the XML for the mappings with Hibernate. There are no miracles!
    Yep, i agree but this has to do with mapping stuff only, it doesn't try to generate, say, new validation rules for me.

    I still don't clearly undesrtand how it all actually works. A simple example would be very helpful.

    Ok, let's get to the lowest technical details. For example i have the following simple model:
    PHP Code:

    <?php

    class Author
    {
       var 
    $bids;
       var 
    $name;

       function 
    __construct($name)
       {
         
    $this->name $name;
         
    $this->bids = new ObjectCollection();
       }
       
       function 
    getName()
       {
         return 
    $this->name;
       }
       
       function 
    addBid($bid)
       {
         
    $bid->setAuthor($bid);
         
    $this->bids->add($bid);
       }
       
       function 
    getBids()
       {
         return 
    $this->bids;
       }
    }

    class 
    Item
    {
      var 
    $name;
      
      function 
    __construct($name)
      {
        
    $this->name $name;
      }
      
      function 
    getName()
      {
        return 
    $this->name;
      }
    }

    class 
    Bid
    {
      var 
    $item;
      var 
    $price;
      var 
    $validity_period;
      var 
    $author;
      
      function 
    __construct($item$price$validity_period)
      {
        
    $this->item $item;
        
    $this->price $price;
        
    $this->validity_period $validity_period;
      }
      
      function 
    getValidityPeriod()
      {
        return 
    $this->validity_period;
      }
      
      function 
    getItem()
      {
        return 
    $this->item;
      }
      
      function 
    getPrice()
      {
        return 
    $this->price;
      }
      
      function 
    setAuthor($author)
      {
        
    $this->author $author;
      }
      
      function 
    getAuthor()
      {
        return 
    $this->author;
      }
    }

    $author = new Author('Joe');

    $item1 = new Item('Rusty car');
    $item2 = new Item('Laptop');

    $bid1 = new Bid($item1, new Money(1000, new Currency('US')), new DatePeriod('2005-12-01''2005-12-10'));
    $bid2 = new Bid($item2, new Money(350, new Currency('US')), new DatePeriod('2005-10-01''2005-11-01'));

    $author->addBid($bid1);
    $author->addBid($bid2);

    ?>
    How would i map it to DB with Metastorage?

  11. #11
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pachanga
    Yep, i agree but this has to do with mapping stuff only, it doesn't try to generate, say, new validation rules for me.
    Right. As I said, if you do not use any of the supported validation, Metastorage would not generate validate type functions.

    Quote Originally Posted by pachanga
    I still don't clearly undesrtand how it all actually works. A simple example would be very helpful.

    Ok, let's get to the lowest technical details. For example i have the following simple model:
    PHP Code:
     snip 
    How would i map it to DB with Metastorage?
    Ok I wrote an equivalent Metastorage component definition of your auction system, but for some reason I was not able to paste it in this message. So this link points to pastebin.

    Now just a few notes:

    - Your code missed the definition of a few classes (Money, Currency, DatePeriod), so I added them myself based on my guess of what those classes should be. I think that in some cases a separate class would not be needed, but that is a design decision.

    - There are a couple of get function definitions because this kind of function is not yet available in the version of Metastorage available for download.

    - Constructors go in the factory class. The factory is a special class responsible for establishing connections. It is also needed by all Metastorage generated classes to keep track of all objects created by the code to avoid the existence of multiple inconsistent copies of the each object in memory.

    - Constructors do not yet support object initialization parameter values. That is on my todo list.

    - As you may see, your classes definitions did not need any custom types of functions as Metastorage can implement all types of functions that this model needs. If you need to implement any other custom functions, you would be allowed to enter PHP code directly in the function definition (not MetaL or any form of XML code tags).

    - You can try using Metastorage now with this component definition file and build it to let you see what Metastoage generates.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  12. #12
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll try pasting your pastebin code here...

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <component>
    
      <name>Auction</name>
      <description>Auction bid system</description>
    
      <class>
        <name>Author</name>
    
        <variable>
          <name>name</name>
          <type>text</type>
        </variable>
    
        <collection>
          <name>bids</name>
          <class>Bid</class>
          <reference>author</reference>
        </collection>
    
        <function>
          <name>addBid</name>
          <type>addtocollection</type>
          <parameters>
            <collection>bids</collection>
            <object>
              <argument>bid</argument>
            </object>
          </parameters>
        </function>
    
    <!--
        <function>
          <name>getName</name>
          <type>get</type>
          <parameters>
            <variable>name</name>
          </parameters>
        </function>
    -->
    
        <function>
          <name>getBids</name>
          <type>getcollection</type>
          <parameters>
            <collection>bids</collection>
          </parameters>
        </function>
    
        <function>
          <name>saveAuthor</name>
          <type>persist</type>
        </function>
    
      </class>
    
      <class>
        <name>Item</name>
    
        <variable>
          <name>name</name>
          <type>text</type>
        </variable>
    
    <!--
        <function>
          <name>getName</name>
          <type>get</type>
          <parameters>
            <variable>name</variable>
          </parameters>
        </function>
    -->
    
        <function>
          <name>saveItem</name>
          <type>persist</type>
        </function>
    
      </class>
    
      <class>
        <name>Currency</name>
    
        <variable>
          <name>symbol</name>
          <type>text</type>
          <length>2</length>
        </variable>
    
        <function>
          <name>saveCurrency</name>
          <type>persist</type>
        </function>
    
      </class>
    
      <class>
        <name>Money</name>
    
        <variable>
          <name>amount</name>
          <type>decimal</type>
        </variable>
    
        <variable>
          <name>currency</name>
          <class>Currency</class>
        </variable>
    
        <function>
          <name>saveItem</name>
          <type>persist</type>
        </function>
    
      </class>
    
      <class>
        <name>DatePeriod</name>
    
        <variable>
          <name>start</name>
          <type>date</type>
        </variable>
    
        <variable>
          <name>end</name>
          <type>date</type>
        </variable>
    
        <function>
          <name>saveDatePeriod</name>
          <type>persist</type>
        </function>
    
      </class>
    
      <class>
        <name>Bid</name>
    
        <variable>
          <name>item</name>
          <class>Item</class>
        </variable>
    
        <variable>
          <name>price</name>
          <class>Money</class>
        </variable>
    
        <variable>
          <name>validity_period</name>
          <class>DatePeriod</class>
        </variable>
    
        <variable>
          <name>author</name>
          <class>Author</class>
        </variable>
    
        <function>
          <name>getValidityPeriod</name>
          <type>getreference</type>
          <parameters>
            <variable>validity_period</variable>
          </parameters>
        </function>
    
        <function>
          <name>getItem</name>
          <type>getreference</type>
          <parameters>
            <variable>item</variable>
          </parameters>
        </function>
    
        <function>
          <name>getPrice</name>
          <type>getreference</type>
          <parameters>
            <variable>price</variable>
          </parameters>
        </function>
    
        <function>
          <name>setauthor</name>
          <type>setreference</type>
          <parameters>
            <variable>author</variable>
            <reference>
              <argument>author</argument>
            </reference>
          </parameters>
        </function>
    
        <function>
          <name>getAuthor</name>
          <type>getreference</type>
          <parameters>
            <variable>author</variable>
          </parameters>
        </function>
    
        <function>
          <name>saveBid</name>
          <type>persist</type>
        </function>
    
      </class>
    
      <factory>
    
        <function>
          <name>newAuthor</name>
          <type>createobject</type>
          <parameters>
            <class>Item</class>
          </parameters>
        </function>
    
        <function>
          <name>newItem</name>
          <type>createobject</type>
          <parameters>
            <class>Item</class>
          </parameters>
        </function>
    
        <function>
          <name>newCurrency</name>
          <type>createobject</type>
          <parameters>
            <class>Currency</class>
          </parameters>
        </function>
    
        <function>
          <name>newMoney</name>
          <type>createobject</type>
          <parameters>
            <class>Money</class>
          </parameters>
        </function>
    
        <function>
          <name>newDatePeriod</name>
          <type>createobject</type>
          <parameters>
            <class>DatePeriod</class>
          </parameters>
        </function>
    
        <function>
          <name>newBid</name>
          <type>createobject</type>
          <parameters>
            <class>Bid</class>
          </parameters>
        </function>
    
      </factory>
    
      <schema>
    
        <function>
          <name>installSchema</name>
          <type>installschema</type>
        </function>
    
      </schema>
    
    </component>
    I'm a bit confused with this mapping schema because it doesn't simply describe mapping, it obviously does more ...hm, there will be more questions in a while.

  13. #13
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some more questions before i try generating code with Metastorage:

    - your mapping schema doesn't define any db mapping, i.e no db tables, no fields, how would Metastorage guess that?
    - i find a bit strange describing methods of the model in the mapping schema, e.g "<function><name>addBid</name>...", why?
    - Money, Currency, DatePeriod are value objects, they're not entities, how would i define that?
    - could you please show an example of usage of persistence layer with my model? I.e CRUD example, something as the following could shed some more light:

    PHP Code:
    $author = new Author('Joe');

    $item1 = new Item('Rusty car');
    $item2 = new Item('Laptop');

    $bid1 = new Bid($item1, new Money(1000, new Currency('US')), new DatePeriod('2005-12-01''2005-12-10'));
    $bid2 = new Bid($item2, new Money(350, new Currency('US')), new DatePeriod('2005-10-01''2005-11-01'));

    $author->addBid($bid1);
    $author->addBid($bid2); 

    //i'm only guessing here
    $ts Metastorage :: startTransaction();
    $ts->register($author);
    $ts->commit();

    $ts Metastorage :: startTransaction();
    $it $ts->find('author like "joe"');
    $it->rewind();
    $it->next();
    $author $it->current();

    $ts->delete($author);
    $ts->commit(); 

  14. #14
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pachanga
    - your mapping schema doesn't define any db mapping, i.e no db tables, no fields, how would Metastorage guess that?
    Classes and variables are mapped to tables and fields with the same names.

    If you generate your component code, you can see that Metastorage generated a file named Auction.schema that defines your database schema.

    If you would have many-many relationships, Metastorage would have generated also intermediate tables to store the identifiers of the objects of the related classes.


    Quote Originally Posted by pachanga
    - i find a bit strange describing methods of the model in the mapping schema, e.g "<function><name>addBid</name>...", why?
    I assume that for each Author there would be 0 or more associated Bids . That 1-many relationship is represented by the bids collection.

    The addBid of function does the same as the addBid function in your original class. It is a function of type addtocollection that adds a Bid object to the collection of bids of an Author.


    Quote Originally Posted by pachanga
    - Money, Currency, DatePeriod are value objects, they're not entities, how would i define that?

    Since the information of those classes also has to be stored, I added their class definitions to your component.

    Personally I would not define them as separate classes because that is inefficient. Each class maps to a separate table.

    I would rather turn the price variable of the Bid class into a decimal variable, add a price_currency variable to store the currency symbol, convert the validity_period object reference variable into two date variables named validity_period_start and validity_period_end. That way I would not need those other classes, but that is a design decision that you need to ponder.

    Quote Originally Posted by pachanga
    - could you please show an example of usage of persistence layer with my model? I.e CRUD example, something as the following could shed some more light:
    First let me clarify that Metastorage generated code is self-contained. This means that the generated code does not use any libraries to implement object persistence operations. It just makes direct calls to the database abstraction package and that is all it needs.

    Quote Originally Posted by pachanga
    PHP Code:
    $author = new Author('Joe');

    $item1 = new Item('Rusty car');
    $item2 = new Item('Laptop');

    $bid1 = new Bid($item1, new Money(1000, new Currency('US')), new DatePeriod('2005-12-01''2005-12-10'));
    $bid2 = new Bid($item2, new Money(350, new Currency('US')), new DatePeriod('2005-10-01''2005-11-01'));

    $author->addBid($bid1);
    $author->addBid($bid2); 

    //i'm only guessing here
    $ts Metastorage :: startTransaction();
    $ts->register($author);
    $ts->commit();

    $ts Metastorage :: startTransaction();
    $it $ts->find('author like "joe"');
    $it->rewind();
    $it->next();
    $author $it->current();

    $ts->delete($author);
    $ts->commit(); 
    To implement that, you need a few more functions in your component.

    To retrieve all Authors named joe, you need a factory function of type getallobjects and associate it a filter expression defined in Metastorage OQL (Object Query Language) to define the search condition to match the name joe. It would look like this:

    Code:
    <function>
      <name>getAuthorsNamedJoe</name>
      <type>getallobjects</type>
      <parameters>
    
        <class>Author</class>
    
        <filter>
            <variable>
              <name>name</name>
            </variable>
          <equalto />
            <text>joe</text>
        </filter>
    
      </parameters>
    </function>
    Anyway, I suspect that it is not what you want, but rather to retrieve all Authors with a name given at runtime. You can achieve that by adding an argument to the function and make the filter OQL expression use that argument value instead of the constant text joe.

    Code:
    <function>
      <name>getAuthorsByName</name>
      <type>getallobjects</type>
      <argument>
        <name>name</name>
        <type>text</type>
      </argument>
      <parameters>
    
        <class>Author</class>
    
        <filter>
            <variable>
              <name>name</name>
            </variable>
          <equalto />
            <argument>name</argument>
        </filter>
    
      </parameters>
    </function>
    You also need a function of type delete in the Author class that would be declared like this:

    Code:
    <function>
      <name>deleteAuthor</name>
      <type>delete</type>
    </function>
    So, your could above would look more or less like this omiting error handling:

    PHP Code:
    $factory = &new Auctionclass;

    $author = &$factory->newAuthor;
    $author->name 'Joe';
    $author->saveAuthor();

    $item1 = &$factory->newItem;
    $item1->name 'Rusty car';
    $item1->saveItem();
    $item2 = &$factory->newItem;
    $item2->name='Laptop';
    $item2->saveItem();

    $bid1 = &$factory->newBid();
    $bid1->setItem($item1);
    $price = &$factory->newMoney;
    $price->amount=1000;
    $currency = &$factory->newCurrency;
    $curreny->symbol 'US';
    $currency->saveCurrency();
    $price->setCurrency($currency);
    $date_period = &$factory->newDatePeriod;
    $date_period->start '2005-12-01';
    $date_period->end '2005-12-10';
    $date_period->saveDatePeriod();
    $bid1->setDatePeriod($date_period);
    $bid1->saveBid();

    $bid2 = &$factory->newBid();
    $bid2->setItem($item2);
    $price = &$factory->newMoney;
    $price->amount 350;
    $price->setCurrency($currency);
    $date_period = &$factory->newDatePeriod;
    $date_period->start '2005-10-01';
    $date_period->end '2005-11-01';
    $date_period->saveDatePeriod();
    $bid2->setDatePeriod($date_period);
    $bid2->saveBid();

    $author->addBid($bid1);
    $author->addBid($bid2); 

    $authors= &$factory->findAuthorsByName('joe');
    $author = &$authors[0];

    $author->delete($author); 
    The code could be simpler if the values for prices, currencies and date periods woul not be in separate classes, as I suggested above.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  15. #15
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yikes, but that's ...er...non-acceptable for me...

    Maybe i got something wrong from your example(but something tells me i'm right)...

    So, your could above would look more or less like this omiting error handling:
    I want to work exactly with my model(the one i showed in the very first example) not some strange and clumsy autogenerated code. Is my model preserved somehow or is it obscured with Metastorage autogenerated code? Do i have, for example, to use "$author = &$factory->newAuthor;" instead of "$author = new Author('Joe')" all the time? Yes, i know Hibernate does affect on the model by introducing some conventions and requirements but they're very logical.

    Money, Currency, DatePeriod are value objects, they're not entities, how would i define that?
    Personally I would not define them as separate classes because that is inefficient. Each class maps to a separate table.
    That's nonsense. They're value objects not entities! A mature ORM tool should provide seamless support for those. Yes, table 'bid' will actually contain date fields 'validity_period_start' and 'validity_period_end' but the ORM subsystem will transparently map it to DatePeriod object not just scalar values. The same story is about Money and Currency. It's a serious flaw if Metastorage doesn't support that...

    Classes and variables are mapped to tables and fields with the same names.
    Is this a mandatory requirement? It's pretty much a big limitation if so...

    I think we've been talking about different things all the time. What i'm trying to say is that a full blown ORM solution(as you claim Metastorage is) should never mess with the business model. I asked you for several times the same question and you replied that Metastorage doesn't behave like that. And now what do we see? My nice model is all covered with weird calls to Metastorage subsystem. I wrote a simple example showing how usually a persistence layer interacts with the model and Metastorage doesn't even get that close

    Seriously, how can you compare Metastorage with Hibernate after that?...

  16. #16
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pachanga
    I want to work exactly with my model(the one i showed in the very first example) not some strange and clumsy autogenerated code.
    Why are you saying the autogenerated code is clumsy? Did you actually look at the code generated by Metastorage?

    Quote Originally Posted by pachanga
    Is my model preserved somehow or is it obscured with Metastorage autogenerated code?
    As I already said several times the generated model classes bundle the necessary code to make the objects persistent, but you are the one that actually defines the API of your model classes.


    Quote Originally Posted by pachanga
    Do i have, for example, to use "$author = &$factory->newAuthor;" instead of "$author = new Author('Joe')" all the time? Yes, i know Hibernate does affect on the model by introducing some conventions and requirements but they're very logical.
    Yes. You may consider that a requirement introduced by Metastorage generated code. The reason for that is simple, although it is not obvious for somebody that did not read the Metastorage documentation.

    The factory class is responsible for managing the life of the persistent objects. That means that among other things, the factory class prevents that multiple copies of the same object exist in memory.

    For instance if you create an object, store it, then execute a query that would return that same object, the factory class would return a reference to the object that your created rather than a copy.

    This is important to prevent that your applications inadvertedly corrupt the information of your objects by having different parts of your script updating different copies of the same object.



    Quote Originally Posted by pachanga
    That's nonsense. They're value objects not entities! A mature ORM tool should provide seamless support for those. Yes, table 'bid' will actually contain date fields 'validity_period_start' and 'validity_period_end' but the ORM subsystem will transparently map it to DatePeriod object not just scalar values. The same story is about Money and Currency. It's a serious flaw if Metastorage doesn't support that...
    Maybe, but let me note that if your are looking for the perfect ORM, I am afraid it does not exist.

    So, either you make a serious effort to try to understand and adapt to what the available ORM solutions can do, or soon you will find yourself tempted to spend years of development to replicate what other ORM did but without the limitations that you found.

    That is what I did 3 years ago. Still Metastorage is now much more complete than what it was when I made the first release. Furthermore it will continue to improve to address better the needs of everybody that is genuinely interested to use it.

    I do not have the pretension to claim that Metastorage is perfect for you. From what you told me, I honestly believe that Metastorage can solve your object persistence problems, even though it may not work exactly that way you thought it would work better.




    Quote Originally Posted by pachanga
    Is this a mandatory requirement? It's pretty much a big limitation if so...
    Currently classes and variables map to tables and fields of the same name. Making it map to tables or fields with different names would not be a big deal. It happens that nobody requested that before. I could add that capability to Metastorage if that would make a big difference for you.

    Quote Originally Posted by pachanga
    I think we've been talking about different things all the time. What i'm trying to say is that a full blown ORM solution(as you claim Metastorage is) should never mess with the business model. I asked you for several times the same question and you replied that Metastorage doesn't behave like that. And now what do we see? My nice model is all covered with weird calls to Metastorage subsystem. I wrote a simple example showing how usually a persistence layer interacts with the model and Metastorage doesn't even get that close

    Seriously, how can you compare Metastorage with Hibernate after that?...
    I think either I am not expressing myself correctly or you are not making a serious effort to understand what I am saying.

    What I always said is that Metastorage approach is different than Hibernate. I also said that from what I could see Metastorage approach seemed less complicated. Given this, if you want a complicate approach as Hibernate that makes you create several types of files (model, dao, mappings, etc.) for each persistent object class, Metastorage is not that.

    What I tried to to explain is that Metastorage can generate your model classes with the same API but bundling all the necessary code to make your objects persistent. For that you need to add the necessary function definitions that make your model classes have the persistence features that you need. If that is not yet clear for you, Metastorage generates code according to what you tell it to generate. So you are in control.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  17. #17
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mlemos
    Why are you saying the autogenerated code is clumsy? Did you actually look at the code generated by Metastorage?
    Because it's an autogenerated code. It should not mess with my model. Period.

    As I already said several times the generated model classes bundle the necessary code to make the objects persistent, but you are the one that actually defines the API of your model classes.
    Yes, but it's not my model. It's something that Metastorage dictates me to use. It's really funny, you keep saying that Metastorage doesn't mangle my model my model when obviously it does. It was the very first question i asked you about and it's only a few posts back we discovered how "transparent" and "unobtrosive" Metastorage is.

    Yes. You may consider that a requirement introduced by Metastorage generated code. The reason for that is simple, although it is not obvious for somebody that did not read the Metastorage documentation.
    Hooray, you finally admit that


    Maybe, but let me note that if your are looking for the perfect ORM, I am afraid it does not exist.
    Of course, there's no such an ORM tool which would completely satisfy everyone, however Hibernate does get very close to be called the perfect one.

    I do not have the pretension to claim that Metastorage is perfect for you. From what you told me, I honestly believe that Metastorage can solve your object persistence problems, even though it may not work exactly that way you thought it would work better.
    Nope it can't. I don't want my team to use ugly API of the autogenerated code as a model, i would rather code datamappers myself.

    What I always said is that Metastorage approach is different than Hibernate. I also said that from what I could see Metastorage approach seemed less complicated. Given this, if you want a complicate approach as Hibernate that makes you create several types of files (model, dao, mappings, etc.) for each persistent object class, Metastorage is not that.
    Have you really ever tried Hibernate yourself? You should not compare Hibernate and Metastorage if not. You wouldn't believe it but, for example, EZPDO approach is way more "hibernatish" than Metastorage...

    The bottom line is that instead of praising and hyping Metastorage you should give mere facts about it. Authors of other ORM solutions admit their limits and don't recommend it just for everyone.

    I do respect your hard work but i think it's dishonest not mentioning Metastorage limitations and consequences for the model in the very first place instead of advertising auto forms and UML building features.
    Last edited by pachanga; Oct 10, 2005 at 02:52.

  18. #18
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    many to many relationship within the same entity

    hi

    i would like to know if metastorage can handle many to many relationship within the same entity and how to implement.given this situation i have a table person.Every person is related to another person..
    how to describe such a relationship with the CPML.........i have read the metastorage tutorial it only talks about a spouse related to person ( 1 to 1 relationship within the same entity)..please can anyone provide me with the codes of how to write it........

    possibly what am tryng to create is a person can have may friends so related to another person which in again related to other persons....a looping relationship within the same class......

    e.g rita knows john (instances of class person)
    john knows mike
    mike knows sam.
    and it goes on.....
    i want to retrieve all people related to say john(directly and indirectly)
    hence the query should retrieve all people related like rita,mike and also sam


    to be simple a database shema as such

    Person table
    PId PK
    Name varchar

    Knows Table
    PId PK
    Pid PK

    The table knows consists of 2 primary keys acting as foreign keys also...
    i am not quite sure if its ok......
    but can anyone help me how to do it in metastorage and how the database design should be.

    i hope to get a quick answer and help please it concerns a project whose deadline is surely approaching.

    Thanks for answering in advance

  19. #19
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tos
    i would like to know if metastorage can handle many to many relationship within the same entity and how to implement.given this situation i have a table person.Every person is related to another person..
    Sure, it can.

    Quote Originally Posted by tos
    how to describe such a relationship with the CPML.........i have read the metastorage tutorial it only talks about a spouse related to person ( 1 to 1 relationship within the same entity)..please can anyone provide me with the codes of how to write it........

    possibly what am tryng to create is a person can have may friends so related to another person which in again related to other persons....a looping relationship within the same class......
    Got it, just define your person class with two collections that reference each other: one for people that the person knows, lets call that knows, and another for people that knows that person, lets call that known_by. In this case the person class would look like this:

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <component>
    
      <name>networking</name>
    
      <description>Network of known people</description>
    
      <class>
    
        <name>person</name>
    
        <variable>
          <name>name</name>
          <type>text</type>
          <length>30</length>
        </variable>
    
        <!-- ... other variables and definitions here -->
    
        <collection>
          <name>knows</name>
          <class>person</class>
          <reference>known_by</reference>
        </collection>
    
        <collection>
          <name>known_by</name>
          <class>person</class>
          <reference>knows</reference>
        </collection>
    
        <function>
          <name>addKnownPerson</name>
          <type>addtocollection</type>
          <parameters>
            <collection>knows</collection>
            <object>
              <argument>person</argument>
            </object>
          </parameters>
        </function>
    
        <function>
          <name>addPersonThatKnows</name>
          <type>addtocollection</type>
          <parameters>
            <collection>known_by</collection>
            <object>
              <argument>person</argument>
            </object>
          </parameters>
        </function>
    
        <function>
          <name>getAllKnown</name>
          <type>getcollection</type>
          <parameters>
            <collection>knows</collection>
          </parameters>
        </function>
    
        <function>
          <name>getAllKnownBy</name>
          <type>getcollection</type>
          <parameters>
            <collection>known_by</collection>
          </parameters>
        </function>
    
        <function>
          <name>savePerson</name>
          <type>persist</type>
        </function>
    
      </class>
    
      <factory>
      </factory>
    
      <schema>
        <function>
          <name>installSchema</name>
          <type>installschema</type>
        </function>
      </schema>
    
    </component>


    Quote Originally Posted by tos
    e.g rita knows john (instances of class person)
    john knows mike
    mike knows sam.
    and it goes on.....
    i want to retrieve all people related to say john(directly and indirectly)
    hence the query should retrieve all people related like rita,mike and also sam
    Get all directly related can be achieved by getAllKnown and getAllKnownBy functions declared above. Get all indirectly it is tricky. I never tried but I think you can express that with a search filter argument to associate to a getcollection function that would perform the necessary joins.


    Quote Originally Posted by tos
    to be simple a database shema as such

    Person table
    PId PK
    Name varchar

    Knows Table
    PId PK
    Pid PK

    The table knows consists of 2 primary keys acting as foreign keys also...
    i am not quite sure if its ok......
    but can anyone help me how to do it in metastorage and how the database design should be.
    Don't worry about the database design. Metastorage also generates that for you from the component design. If you tell Metastorage to generate the component above, it also generates a schema definition in Metabase schema XML format like this:


    This XML file does not appear to have any style information associated with it. The document tree is shown below.

    Code:
          
    <database>
    
      <name><variable>name</variable></name>
    
      <create><variable>create</variable></create>
    
      <table>
        <name>person</name>
    
        <declaration>
    
          <field>
             <name>id</name>
             <autoincrement>1</autoincrement>
          </field>
    
          <field>
            <name>name</name>
            <type>text</type>
            <notnull>1</notnull>
            <default/>
            <length>30</length>
          </field>
    
        </declaration>
    
      </table>
    
      <table>
        <name>person_known_by_person_knows</name>
    
        <declaration>
    
          <field>
            <name>person_known_by</name>
            <type>integer</type>
            <notnull>1</notnull>
            <default>0</default>
          </field>
    
          <field>
            <name>person_knows</name>
            <type>integer</type>
            <notnull>1</notnull>
            <default>0</default>
          </field>
    
          <primarykey>
            <field>
              <name>person_known_by</name>
            </field>
    
            <field>
              <name>person_knows</name>
            </field>
          </primarykey>
    
        </declaration>
    
      </table>
    
    </database>

    Quote Originally Posted by tos
    i hope to get a quick answer and help please it concerns a project whose deadline is surely approaching.
    No problem, once you know what you want, using Metastorage is quite straightforward. ;-)
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  20. #20
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's nonsense.


    You can't just push their responsibilities onto the ORM tool

    I want to work exactly with my model(the one i showed in the very first example) not some strange and clumsy autogenerated code.
    This is the problem right there I think? The other day there I had started a thread on how best to separate your various SQL in an application, by database vendor. Mlemos too suggested that I use Metastorage, but I took note that it wasn't suitable for my needs.

    I still don't, but reading over this thread, there is now a certain premise of just where does Metastorage fit in if it's neither suitable for either my needs, or yours? Doubtful I know, but maybe we're clueless huh?

    Maybe Mlemos knows something we don't

  21. #21
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe Mlemos knows something we don't...
    Yep, i feel the same

    BTW, i wonder what happens with Metastorage mappings if business model rules change somehow. Say, an author is not allowed to have bids whose date periods overlap, e.g:

    PHP Code:

    class Author
    {
      [...]
      function 
    addBid($new_bid)
      {
        foreach(
    $this->bids as $bid)
        {
          if(
    $bid->getDatePeriod()->intersects($new_bid->getDatePeriod()))
            throw new 
    BusinessException('Buids can not overlap!');
        }
        
        
    $bid->setAuthor($bid);
        
    $this->bids->add($new_bid);
      }
      [...]

    Do i have to describe this with XML?

  22. #22
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pachanga
    BTW, i wonder what happens with Metastorage mappings if business model rules change somehow. Say, an author is not allowed to have bids whose date periods overlap, e.g:

    PHP Code:

    class Author
    {
      [...]
      function 
    addBid($new_bid)
      {
        foreach(
    $this->bids as $bid)
        {
          if(
    $bid->getDatePeriod()->intersects($new_bid->getDatePeriod()))
            throw new 
    BusinessException('Buids can not overlap!');
        }
        
        
    $bid->setAuthor($bid);
        
    $this->bids->add($new_bid);
      }
      [...]

    Do i have to describe this with XML?
    As I mentioned before you can define custom functions that will be integrated by Metastorage generated code.

    Instead of this:

    Code:
    <function>
      <name>addBid</name>
      <type>addtocollection</type>
      <parameters>
        <collection>bids</collection>
        <object>
          <argument>bid</argument>
        </object>
      </parameters>
    </function>
    You would define this:

    Code:
    <function>
      <name>addBid</name>
      <type>custom</type>
      <argument>
        <name>bid</name>
      </argument>
      <parameters>
        <language>PHP</language>
        <do>
    
        foreach($this->bids as $bid)
        {
          if($bid->getDatePeriod()->intersects($new_bid->getDatePeriod()))
            throw new BusinessException('Buids can not overlap!');
        }
        
        $bid->setAuthor($bid);
        $this->bids->add($new_bid);
    
        </do>
        <return>boolean</return>
      </parameters>
    </function>
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  23. #23
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now let's compare your answers:

    Quote Originally Posted by mlemos
    Quote Originally Posted by pachanga
    4) Developer must program his domain model using XML, i think this is what Metal is for.
    If all above is true it's simply unacceptable for me, i don't want to learn Metal and want my model to be controlled only by me.
    No, that is a misconception that was spread by Propel author. I wish Open Source authors did not need to mislead to attract users to their packages.
    You claim that one doesn't have to program XML, now have a look:

    Quote Originally Posted by mlemos
    As I mentioned before you can define custom functions that will be integrated by Metastorage generated code.

    Instead of this:

    Code:
    <function>
      <name>addBid</name>
      <type>addtocollection</type>
      <parameters>
        <collection>bids</collection>
        <object>
          <argument>bid</argument>
        </object>
      </parameters>
    </function>
    You would define this:

    Code:
    <function>
      <name>addBid</name>
      <type>custom</type>
      <argument>
        <name>bid</name>
      </argument>
      <parameters>
        <language>PHP</language>
        <do>
    
        foreach($this->bids as $bid)
        {
          if($bid->getDatePeriod()->intersects($new_bid->getDatePeriod()))
            throw new BusinessException('Buids can not overlap!');
        }
        
        $bid->setAuthor($bid);
        $this->bids->add($new_bid);
    
        </do>
        <return>boolean</return>
      </parameters>
    </function>
    Last edited by pachanga; Oct 10, 2005 at 00:06.

  24. #24
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pachanga
    Now let's compare your answers:

    You claim that one doesn't have to program XML, now have a look:
    I note that your problem is that you do not pay attention to what I am telling you. Then you blame me for your lack of attention and even resort to personal insult by calling me dishonest. Have you ever considered that you are the one with difficulty to understand?

    What I said and you omitted in your quote is that you do not have to write customizations in MetaL language. I even quoted Metastorage FAQ explaining that the XML that is used by CPML (Metastorage format for defining components) has nothing to do with the XML used in MetaL programs.

    In the example that shows how to write a custom functions I pasted your PHP function. The XML tags that surround it are just for telling Metastorage that is a custom function. That is not MetaL code. If you still have difficulty to understand this, I give up, as I am repeating myself more times than what I consider reasonable.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  25. #25
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mlemos
    I note that your problem is that you do not pay attention to what I am telling you. Then you blame me for your lack of attention and even resort to personal insult by calling me dishonest. Have you ever considered that you are the one with difficulty to understand?
    Please don't take it personal, i apologize if i sounded harsh. You recommend Metastorage to everyone in every db related thread and i simply wanted to give it a real test-drive. I got really interested in Metastorage since you keep saying that "Metastorage approach seemed less complicated (less development steps), more efficient" than that of Hibernate which simply turned out not true for me and this is what i'm trying to point at.

    Ok, here's my short Metastorage summary:

    - it really does map some dictated to a developer model described with its own XML schema where you can mix XML markup with PHP

    - maps the model in a very straight-forward manner: one class - one table and it seems to be impossible to customize this behavior

    - doesn't support value objects

    - it's not valid to compare Hibernate and Metastorage, since the former is way more comprehensive and flexible

    - there is a lot of extra stuff for Metastorage: auto forms builder, UML builder, XML schema builder using UML, etc...



    There're still many other questions, e.g:

    - does it support lazy loading and eager fetching of collections? And if yes how can it be controlled from mapping schema?

    - does it wrap object persistent attributes with proxies in order not to load a full graph of objects?

    - does it have some sort if IdentityMap implementation in order to cache already fetched objects?

    - what is the entity uid generation mechanism?
    Last edited by pachanga; Oct 11, 2005 at 00:44.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •