My Quotes


When U were born , you cried and the world rejoiced
Live U'r life in such a way that when you go
THE WORLD SHOULD CRY






Tuesday, December 8, 2015

Repeated columns in JPA


I wanted to define repeated columns in JPA. But when I do, I got the message the second column should be defined as insert="false" , update="false"


 Approach 1: Here is an easy way to do it. In the entity bean define the second property as follows 

        @Column(name="UPLOAD_DATE")
        private Date uploadDate;
        @AttributeOverride(name="uploadDateAsTime", column = @Column
                        (name = "UPLOAD_DATE"))
        private Timestamp uploadDateAsTime;
        @Column(name="UPLOAD_STATUS")
 

 Approach 2: Here is the alternatie way to do it via XML file.. 


it would take care of giving unique names for enbeddable field columns in target entity class.

                
                
                 ddl, callback 
                

No comments :