Total members 11854 |It is currently Fri Jul 30, 2021 3:33 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





If any entity x related to entity y . and x refresh function called , y refresh function is called automatically. refresh means reload the values from database .

Code:

package com
.codemiles.jpa;

import java.util.Collection;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.OneToMany;
@
Entity
@Table(name="COURSE")
public class 
Course implements java.io.Serializable{
    
/**
     * 
     */
    
private static final long serialVersionUID 1L;
    @
Id
    
private long Id;
    private 
String name;
    private 
Long credit;
    private 
Date startDate;
    private 
String department;
    @
OneToMany(mappedBy="course",cascade=CascadeType.REFRESH)
    private 
Collection<Student_Coursestudent_courses;
 
    public  
long getId() {
        return 
Id;
    }
    public 
void setIdlong id) {
        
Id id;
    }
    @
Column(name="NAME")
    public 
String getName() {
        return 
name;
    }
    public 
void setName(String name) {
        
this.name name;
    }
    @
Column(name="CREDIT")
    public 
Long getCredit() {
        return 
credit;
    }
    public 
void setCredit(Long credit) {
        
this.credit credit;
    }
    @
Column(name="START_DATE")
    public 
Date getStartDate() {
        return 
startDate;
    }
    public 
void setStartDate(Date startDate) {
        
this.startDate startDate;
    }
    @
Column(name="DEPARTMENT")
    public 
String getDepartment() {
        return 
department;
    }
    public 
void setDepartment(String department) {
        
this.department department;
    }
    public 
void setStudent_courses(Collection<Student_Coursestudent_courses) {
    
this.student_courses student_courses;
    }
    public 
Collection<Student_CoursegetStudent_courses() {
    return 
student_courses;
    }
   
}

 




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : cascade=CascadeType.REFRESH with many to one relation
 one to many relation JPA example     -  
 Cascade.All and persisting related entities directly     -  



Topic Tags

Java JPA






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com