Java tutorial
/* * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.hawaiiframework.sample.model; import static org.apache.commons.lang3.builder.ToStringStyle.SHORT_PREFIX_STYLE; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToOne; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; /** * @author Marcel Overdijk */ @Entity public class Ingredient { @Id @GeneratedValue private Long id; @ManyToOne(optional = false, fetch = FetchType.EAGER) private Recipe recipe; @Column(nullable = false) private Float quantity; @Column(nullable = false, length = 100) private String description; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Recipe getRecipe() { return recipe; } public void setRecipe(Recipe recipe) { this.recipe = recipe; } public Float getQuantity() { return quantity; } public void setQuantity(Float quantity) { this.quantity = quantity; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } @Override public String toString() { return ReflectionToStringBuilder.toString(this, SHORT_PREFIX_STYLE); } }