You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rave.apache.org by "Anne-Hélène TURPIN (JIRA)" <ji...@apache.org> on 2012/06/14 11:07:43 UTC

[jira] [Created] (RAVE-678) Change model's attributes in protected

Anne-Hélène TURPIN created RAVE-678:
---------------------------------------

             Summary: Change model's attributes in protected
                 Key: RAVE-678
                 URL: https://issues.apache.org/jira/browse/RAVE-678
             Project: Rave
          Issue Type: Improvement
          Components: rave-core
            Reporter: Anne-Hélène TURPIN


We would like to extend the rave model persistence. We would like to inherit attributes from the superclass but It's impossible except for the Person model which has protected attributes.

Is it possible to modify it for models in the rave-core component and in the rave-opensocial-core component ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (RAVE-678) Change model's attributes in protected

Posted by "Raminderjeet Singh (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/RAVE-678?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Raminderjeet Singh updated RAVE-678:
------------------------------------

    Attachment: NewPage.java

sample page extension
                
> Change model's attributes in protected
> --------------------------------------
>
>                 Key: RAVE-678
>                 URL: https://issues.apache.org/jira/browse/RAVE-678
>             Project: Rave
>          Issue Type: Improvement
>          Components: rave-core
>            Reporter: Anne-Hélène TURPIN
>         Attachments: NewPage.java
>
>
> We would like to extend the rave model persistence. We would like to inherit attributes from the superclass but It's impossible except for the Person model which has protected attributes.
> Is it possible to modify it for models in the rave-core component and in the rave-opensocial-core component ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (RAVE-678) Change model's attributes in protected

Posted by "Raminderjeet Singh (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/RAVE-678?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295161#comment-13295161 ] 

Raminderjeet Singh commented on RAVE-678:
-----------------------------------------

You can access them using getter/setters. Can you please describe the problem in detail? private vs protected should not be a problem according to me. 
                
> Change model's attributes in protected
> --------------------------------------
>
>                 Key: RAVE-678
>                 URL: https://issues.apache.org/jira/browse/RAVE-678
>             Project: Rave
>          Issue Type: Improvement
>          Components: rave-core
>            Reporter: Anne-Hélène TURPIN
>         Attachments: NewPage.java
>
>
> We would like to extend the rave model persistence. We would like to inherit attributes from the superclass but It's impossible except for the Person model which has protected attributes.
> Is it possible to modify it for models in the rave-core component and in the rave-opensocial-core component ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (RAVE-678) Change model's attributes in protected

Posted by "Anne-Hélène TURPIN (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/RAVE-678?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295136#comment-13295136 ] 

Anne-Hélène TURPIN commented on RAVE-678:
-----------------------------------------

I don't try with this new implementation of the JPA model. But I think it will not work better. The attributes of the JPA model are still private. And, for exemple, if I want to extend the JpaCategory class, I couldn't access to the attributes of the superclass in an other package. (via a named query for exemple)
                
> Change model's attributes in protected
> --------------------------------------
>
>                 Key: RAVE-678
>                 URL: https://issues.apache.org/jira/browse/RAVE-678
>             Project: Rave
>          Issue Type: Improvement
>          Components: rave-core
>            Reporter: Anne-Hélène TURPIN
>         Attachments: NewPage.java
>
>
> We would like to extend the rave model persistence. We would like to inherit attributes from the superclass but It's impossible except for the Person model which has protected attributes.
> Is it possible to modify it for models in the rave-core component and in the rave-opensocial-core component ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (RAVE-678) Change model's attributes in protected

Posted by "Jasha Joachimsthal (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/RAVE-678?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295047#comment-13295047 ] 

Jasha Joachimsthal commented on RAVE-678:
-----------------------------------------

The current model is tightly coupled with the OpenJPA backend. There is already a branch in Rave that adds and extra interface between the model and the actual mapping to a backend system (whether it's a database, nosql store, JCR...). In this way you can make your own implementation and add extra fields.
Branch: http://svn.apache.org/repos/asf/rave/branches/model_interfaces/
This branch will be merged ASAP into trunk when all model classes are behind an interface and everything works as expected
                
> Change model's attributes in protected
> --------------------------------------
>
>                 Key: RAVE-678
>                 URL: https://issues.apache.org/jira/browse/RAVE-678
>             Project: Rave
>          Issue Type: Improvement
>          Components: rave-core
>            Reporter: Anne-Hélène TURPIN
>         Attachments: NewPage.java
>
>
> We would like to extend the rave model persistence. We would like to inherit attributes from the superclass but It's impossible except for the Person model which has protected attributes.
> Is it possible to modify it for models in the rave-core component and in the rave-opensocial-core component ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (RAVE-678) Change model's attributes in protected

Posted by "Anne-Hélène TURPIN (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/RAVE-678?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295649#comment-13295649 ] 

Anne-Hélène TURPIN commented on RAVE-678:
-----------------------------------------

1) Create a custom Category : 

package fr.renater.portal.model; 

@Entity 
@NamedQueries({ @NamedQuery(name = Category.GET_CATEGORY_BY_KEYWORD_IN_DESC, query = "select c from Category c where lower(c.description) like :keyword") }) 
public class Category extends org.apache.rave.portal.model.Category implements BasicEntity, Serializable { 

  private static final long serialVersionUID = 1L; 
  public static final String GET_CATEGORY_BY_KEYWORD_IN_DESC = "Category.getCategoryByKeywordInDesc"; 
  public static final String KEYWORD_PARAM = "keyword"; 

  @Basic 
  @Column(name = "description") 
  @Lob 
  private String description; 
.... 

2) Create a new repository interface : 

package fr.renater.portal.repository; 

public interface CategoryRenaterRepository { 

  /** 
  * Finds the list of category for a given keyword 
  * @param keyword the keyword of the category description to find category for 
  * @return a valid List of category that are contain the keyword on the description 
  */
  List<fr.renater.portal.model.Category> getCategoryByKeywordInDesc(String keyword);
 ... 

3) Create a new repository implementation class : 

package fr.renater.portal.repository.impl; 

@Repository(value="categoryRepository") 
@Primary 
@Transactional 
public class CategoryRenaterRepositoryImpl extends org.apache.rave.portal.repository.impl.JpaCategoryRepository implements CategoryRenaterRepository { 

  @PersistenceContext 
  private EntityManager manager;

  @Override 
  public List<fr.renater.portal.model.Category> getCategoryByKeywordInDesc(String keyword) {  
     TypedQuery<fr.renater.portal.model.Category> category = manager.createNamedQuery(fr.renater.portal.model.Category.GET_CATEGORY_BY_KEYWORD_IN_DESC, fr.renater.portal.model.Category.class); 
    category.setParameter(fr.renater.portal.model.Category.KEYWORD_PARAM, "%"+keyword.trim().toLowerCase()+"%"); 
    return category.getResultList(); 
  } 
  .... 

4) Overlay core-applicationContext.xml with our version that includes component scans of our custom packages. 

5) Create a test class : 

@Transactional 
@RunWith(SpringJUnit4ClassRunner.class) 
@ContextConfiguration(locations = {"classpath:test-dataContext.xml", "classpath:test-applicationContext.xml"}) 
public class CategoryRenaterRepositoryTest { 

  private static final String TEXT1 = "Technology"; 
  private static final String TEXT2 = "Communications"; 

 @Resource(name="categoryRepository") 
  private CategoryRenaterRepository repository; 

 @Test 
  public void getCategoryByKeywordInDesc() { 
     List<fr.renater.portal.model.Category> list = repository.getCategoryByKeywordInDesc("computer"); 
     assertThat(list.size(), is(2)); 
     assertThat(list.get(0).getText(), is(equalTo(TEXT1))); 
     assertThat(list.get(1).getText(), is(equalTo(TEXT2))); 
  } 
... 

If the attributes are private in the Category class, I have this error : 

<openjpa-2.1.1-r422266:1148538 fatal general error> org.apache.openjpa.persistence.PersistenceException: Column "T0.ID" not found; SQL statement: SELECT t0.id, t0.description FROM Category t0 WHERE (LOWER(t0.description) LIKE ? ESCAPE '\') [42122-154] {SELECT t0.id, t0.description FROM Category t0 WHERE (LOWER(t0.description) LIKE ? ESCAPE '\')} [code=42122, state=42S22] FailedObject: select c from Category c where lower(c.description) like :keyword [java.lang.String] 
                
> Change model's attributes in protected
> --------------------------------------
>
>                 Key: RAVE-678
>                 URL: https://issues.apache.org/jira/browse/RAVE-678
>             Project: Rave
>          Issue Type: Improvement
>          Components: rave-core
>            Reporter: Anne-Hélène TURPIN
>         Attachments: NewPage.java
>
>
> We would like to extend the rave model persistence. We would like to inherit attributes from the superclass but It's impossible except for the Person model which has protected attributes.
> Is it possible to modify it for models in the rave-core component and in the rave-opensocial-core component ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (RAVE-678) Change model's attributes in protected

Posted by "Jasha Joachimsthal (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/RAVE-678?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13393698#comment-13393698 ] 

Jasha Joachimsthal commented on RAVE-678:
-----------------------------------------

I wonder if @Inheritance(strategy=InheritanceType.SINGLE_TABLE) on the Category class solves your issue as well
http://openjpa.apache.org/builds/2.1.1/apache-openjpa/docs/jpa_overview_mapping_inher.html
                
> Change model's attributes in protected
> --------------------------------------
>
>                 Key: RAVE-678
>                 URL: https://issues.apache.org/jira/browse/RAVE-678
>             Project: Rave
>          Issue Type: Improvement
>          Components: rave-core
>            Reporter: Anne-Hélène TURPIN
>         Attachments: NewPage.java
>
>
> We would like to extend the rave model persistence. We would like to inherit attributes from the superclass but It's impossible except for the Person model which has protected attributes.
> Is it possible to modify it for models in the rave-core component and in the rave-opensocial-core component ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (RAVE-678) Change model's attributes in protected

Posted by "Raminderjeet Singh (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/RAVE-678?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295039#comment-13295039 ] 

Raminderjeet Singh commented on RAVE-678:
-----------------------------------------

I have extended Rave user object (Person) outside of Rave https://ogce.svn.sourceforge.net/svnroot/ogce/rave-extensions/rave-id-extension/src/main/java/org/apache/rave/portal/model/User.java to add custom fields to User table. These changes make the changes to database fine but when i tried to use this extended object spring gives some class cast exceptions. i am trying to resolve this to release this as rave-extension project as example.Yes you are right it does not work same way for other models. I tried extending Page model. It works well if the extension class in in Rave-code model package but not in my extended project. Please make the required changes and submit a patch. attaching my sample Page extension model
                
> Change model's attributes in protected
> --------------------------------------
>
>                 Key: RAVE-678
>                 URL: https://issues.apache.org/jira/browse/RAVE-678
>             Project: Rave
>          Issue Type: Improvement
>          Components: rave-core
>            Reporter: Anne-Hélène TURPIN
>         Attachments: NewPage.java
>
>
> We would like to extend the rave model persistence. We would like to inherit attributes from the superclass but It's impossible except for the Person model which has protected attributes.
> Is it possible to modify it for models in the rave-core component and in the rave-opensocial-core component ?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira