Edit the annotation in the child class

Ciro
2013-03-10
2013-03-15
  • Ciro

    Ciro - 2013-03-10

    Hi,

    How I can make this possible?

    public class Class1 {

    private String str;
    

    }

    public class Class2 extends Class1 {

    //@Required    
    //private String str
    

    }

    In summary, I would like to edit the Annotation of an attribute in the child class. How can I do this?

     
  • Javier Paniza

    Javier Paniza - 2013-03-13

    Hi Ciro,

    have you tried to define the property again in the child class?


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

     
  • Ciro

    Ciro - 2013-03-13

    I use @Inheritance(strategy = InheritanceType.JOINED), so if I redefine the property in the child class a new column is created in the table. Works, but created a "unnecessary column". How do I set hibernate to not create the column? I will test other strategy and post here.

     
  • Ciro

    Ciro - 2013-03-14

    When I use the SINGLE_TABLE and TABLE_PER_CLASS strategy appears this error: Repeated column in mapping for entity: [...].

    I'm not very pleased, but it worked with the JOIN strategy. Just set the visualization and can even define gets and sets attributes to refer to the parent class (super)

     
  • Javier Paniza

    Javier Paniza - 2013-03-15

    Hi Ciro,

    have you tried to mark the property as @Transient?
    have you tried to define the field as protected instead of private?

    We could add class level annotations for these cases, like this:

     @RequiredProperties("str1")
     public class Class2 extends Class1 {
    

    But it's a very ugly solution, we would duplicate all OX annotation at class level. I don't like it.

    Maybe we could reorganize the inheritance hierarchy of your project, just modeling the things in another way. However, this things are not always easy. If you put here the structure of your classes with real names maybe I could give you some tip.


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

     
  • Ciro

    Ciro - 2013-03-15

    Wow, are many solutions! The @Transient works perfect, I don't know!

    So, the solution was:

    @Entity
    @Inheritance(strategy = InheritanceType.JOINED)
    public class Class1 {
    
    private String str;
    
    }
    
    @Entity
    public class Class2 extends Class1 {
    
    @Required @Transient
    private String str
    
    }
    

    thanks again Javier

     
    Last edit: Ciro 2013-03-15

Log in to post a comment.

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

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks