Sunday, March 25, 2018

JPA: java.lang.StackOverflowError on adding toString method in entity classes

JPA: java.lang.StackOverflowError on adding toString method in entity classes


Entity Class Teacher have toString() problem:

@Entity
public class Teacher {

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;

private String name;

@OneToMany(mappedBy="teacher", cascade={CascadeType.PERSIST})
private Set<Student> students = new HashSet<Student>();

public Teacher() {}
public Teacher(String name) {
this.name = name;
}

public Set<Student> getStudents() {
return students;
}
public void addStudent(Student student) {
students
.add(student);
student
.setTeacher(this);
}
@Override
public String toString() {
return "Teacher[id=" + id + ", name=" + name
+ "]";
}

}

Wednesday, March 21, 2018

login mysql in command window

 C:\MYSQL\bin\ to your PATH
mysql -u user_name -p  then press_enter_key
then type password
i.e.
line-1 : mysql -u root -p

line-2
: admin


1) show databases;


2) use (your preferred database);


3) show tables;


4) select * from (preferred table);

Groovy Setup Eclipse

https://github.com/groovy/groovy-eclipse/wiki


add software ->  select groovy eclipse and compilers
http://dist.springsource.org/snapshot/GRECLIPSE/e4.7

Gradle Setup - Eclipse



Eclipse - Install from Market place - buildship plugin

implementing interfaces in groovy


​interface 
void f()
void g(int n);
void h(String sint n);
}

{Object[args -> println "method called with $args"as 

x.f(
x.g(5
x.h("a string",2)



-----------------------------

interface 
void f();
void g(int n);
void h(String sint n);


f{println "f is called"},
g{int i-> println "g is called with param ${i}"},
h{Object[args -> println "h is called with ${args}"as X

x.f()
x.g(5)
x.h("a string",2)

Tuesday, March 20, 2018

Groovy Master - http://mrhaki.blogspot.in

Groovy Optional Return

def simple({
    "Hello world"
}
assert 'Hello world' == simple()
 
 
def doIt(b{
    if (b{
        "You are true"
    else {
        "You are false"
    }
}
assert 'You are true' == doIt(true)
assert 'You are false' == doIt(false)
 
 
def tryIt(file{
    try {
        new File(file).text
    catch (e{
        "Received exception: ${e.message}"
    finally {
        println 'Finally is executed but nothing is returned.'
        'Finally reached'
    }
}
assert 'Received exception: invalidfilename (The system cannot find the file specified)'  == tryIt('invalidfilename')
// Create new file with the name test.
def newFile new FileWriter('test').withWriter it.write('file contents'}
assert 'file contents' == tryIt('test')

உப்பு மாங்காய்

சுருக்குப்பை கிழவி. சுருக்கங்கள் சூழ் கிழவி. பார்க்கும் போதெல்லாம் கூடையுடனே குடியிருப்பாள். கூடை நிறைய குட்டி குட்டி மாங்காய்கள். வெட்டிக்க...