Search Java Code Snippets

  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.

#Java - Code Snippets for '#Bean' - 4 code snippet(s) found

 Sample 1. Class bean with getter , setter and constructor

public class Employee {
public String name;
public int age;
public int salary;

Employee(String name, int age, int salary) { = name;
this.age = age;
this.salary = salary;

public String getName() {
return name;

public void setName(String name) { = name;

public int getAge() {
return age;

public void setAge(int age) {
this.age = age;

public int getSalary() {
return salary;

public void setSalary(int salary) {
this.salary = salary;

   Like      Feedback     bean   pojo   plain java objects   getters   setters   getters nd setters   classes   class   constructor   parameterized constructor  this keyword

 Sample 2. Hibernate Entity

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Type;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import org.hibernate.annotations.DiscriminatorOptions;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;

@Table(name="Employee", schema = "test")
@Inheritance(strategy= InheritanceType.SINGLE_TABLE)
discriminatorType= DiscriminatorType.STRING
public class Employee {

@SequenceGenerator(name = "", sequenceName = "")
@GeneratedValue(strategy = GenerationType.AUTO, generator = "")
private int employeeId;

private String employeeName;

private String department;

private Boolean isFullTime;

@Column(name = "ACTIVE")
@Type(type = "yes_no")
public boolean getActive() {
return active;

public String getName() {
return employeeName;

public String getDept() {
return department;

   Like      Feedback     Hibernate entity   Hibernate Bean

 Sample 3. Usage of

import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.context.annotation.Bean;
import org.springframework.web.multipart.MultipartResolver;

public class Application extends WebMvcConfigurerAdapter {
public MultipartResolver multipartResolver() {
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
return multipartResolver;

   Like      Feedback     Usage of MultipartResolver  multipartResolver.setMaxUploadSize(500000)  Setting max file size using Spring multipartResolver

 Sample 4. Usage of JavaBean Annotation

@JavaBean(description = "",defaultProperty="",defaultEventSet="")
public class Test {

   Like      Feedback     JavaBean Annotation  java 9

Subscribe to Java News and Posts. Get latest updates and posts on Java from
Enter your email address:
Delivered by FeedBurner

comments powered by Disqus