basics

Showing posts with label basics. Show all posts
Showing posts with label basics. Show all posts

The best way to map @ManyToMany


@ManyToManyMany to many relationships can be easily mapped by creating another table using @JoinTable as follows.Student entity@Data@Table(name = "Student")@Entitypublic class Student implements Serializable {     @Id     @GeneratedValue(strategy = GenerationType.AUTO)...

How to avoid NullPointerException


java.lang.NullPointerExceptionWhen can it be thrown?According to the JavaDoc, the following scenarios can be found.Calling the instance method of a null object.Accessing or modifying the field of a null object.Taking the length of null as if it were an array.Accessing or modifying the slots of null...

Throw vs throws in exception handling


Throw vs throwsThrowThrowsUses inside a method when it is required to throw an exceptionThis is used in the method signature in which methods that exceptions can occur. Only one exception can be thrownThrows can be used to declare multiple exceptionsUsed to handle unchecked exceptionsUsed to handle...