Posts

Showing posts from March, 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 + "]" ; } }

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  X  {  void  f ( ) ;  void  g ( int  n ) ; void  h ( String  s ,  int  n ) ; } x  =  { Object [ ]  args  ->  println  "method called with $args" }  as  X  x . f ( )  x . g ( 5 )  x . h ( "a string" , 2 ) ​ ----------------------------- interface  X  {  void  f ( ) ; void  g ( int  n ) ; void  h ( String  s ,  int  n ) ; }  x  =  [  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 ) ​

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: i...