How to create a custom modules that is defined by a left join statement.

Khanh Tran
2013-03-18
2013-04-02
  • Khanh Tran

    Khanh Tran - 2013-03-18

    I have 2 tables: product(id,name) and product_option(id,product_id,is_taxable). Is it possible to create a module that is defined something like: select * from product left join product_option on product.id = product_option.product_id to provide crud operation for product_option entity.

     
    Last edit: Khanh Tran 2013-03-18
  • Javier Paniza

    Javier Paniza - 2013-03-21

    Hi Khanh,

    you can modeling your classes in that way:

    @Tab(properties="id, product.name, taxable")
    class ProductOption {
        @Id
        String id
    
        @ManyToOne
        Product product
    
        boolean taxable
    }
    
    class Product {
        @Id
        String id
    
        String name
    }
    

    And then use the ProductOption module.


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

     
  • Khanh Tran

    Khanh Tran - 2013-03-29

    How can I create a module that "list all" products, together with its ProductOption if not null. I then can either add new ProductOption or edit existing ProductOption from a selected product in this list. This module must be based from Product module and not ProductOption module. Thank you for your help.

     
    Last edit: Khanh Tran 2013-03-31
  • Javier Paniza

    Javier Paniza - 2013-04-02

    Hi Khanh,

    try a @OneToOne reference in Product, maybe it works:

    class Product {
    
        @OneToOne(mappedBy="product")
        ProductOption option
    
    }
    

    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks