I have 2 tables - Food and Lvl. On every Lvl can be stored a lot of Food.

Lvl class

```
@SequenceGenerator(name = "lvl_seq", sequenceName = "lvl_seq")
@Entity
@Table(name = "Lvl")
public class Lvl {
    @Id
    @GeneratedValue(generator = "lvl_seq")
    @Column(name = "lvl_id")
    private int lvl_id;
    @Column(name = "dimension")
    private String dimension;
    @Column(name = "title")
    private String title;
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "lvl_id")
    private List<Food> foodList;
    //getset
    public int getLvl_id() { return lvl_id; }
    public void setLvl_id(int lvl_id) { this.lvl_id = lvl_id; }
    public String getDimension() { return dimension; }
    public void setDimension(String dimension) { this.dimension = dimension; }
    public String getTitle() { return title; }
    public void setTitle(String title) { this.title = title; }
    public List<Food> getFoodList() { return foodList; }
    public void setFoodList(List<Food> foodList) { this.foodList = foodList; }

}

```

Food class

```
@SequenceGenerator(name = "food_seq", sequenceName = "food_seq")
@Entity
@Table(name = "Food")
public class Food {
    @Id
    @GeneratedValue(generator = "food_seq")
    @Column(name = "food_id")
    private int food_id;
    @Column(name = "location")
    private String location;
    @ManyToOne
    @JoinColumn(name = "lvl_id")
    private Lvl lvl_id;
    //getset
    public int getFood_id() { return food_id; }
    public void setFood_id(int food_id) { this.food_id = food_id; }
    public String getLocation() { return location; }
    public void setLocation(String location) { this.location = location; }
    public Lvl getLvl_id() { return lvl_id; }
    public void setLvl_id(Lvl lvl_id) { this.lvl_id = lvl_id; }
}

```

FoodController

```
@Controller
public class FoodController 
{
    @Autowired
    private LvlService lvlService;
    @Autowired
    private FoodService foodService;
    @RequestMapping("/food")
    public String listFood(Map<String, Object> map) 
    {
        List<Integer> lvl = new ArrayList<>();
        map.put("food", new Food());
        map.put("foodList", foodService.getAll());
        for(Lvl o : lvlService.getAll())
        { 
            lvl.add(o.getLvl_id());
        }
        map.put("lvlList", lvl);

        return "food";
    }
    @RequestMapping(value = "/addFood", method = RequestMethod.POST)
    public String addFood(@ModelAttribute("food") Food food, BindingResult result) 
    {
        foodService.addFood(food);
        return "redirect:/food";
    }
    @RequestMapping("/deleteFood/{foodId}")
    public String deleteFood(@PathVariable("foodId") int id) 
    {
        foodService.removeFood(id);
        return "redirect:/food";
    }  
}

```

And JSP view:

```
<%@ page language="java" contentType="text/html; charset=utf8"
    pageEncoding="utf8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf8">
    <title><spring:message code="label.bookmark" /></title>
</head>
<body>

<a href="<c:url value="/index" />">
    <spring:message code="label.menu" />
</a>

<h3><spring:message code="label.foods" /></h3>

<form:form method="post" action="addFood" commandName="food">
    <table> 
        <tr>
            <td>
            <form:label path="location">
                <spring:message code="label.location" />
            </form:label>
            </td>
            <td>
            <form:input path="location" />
            </td>
        </tr>
        <tr>
            <td>
            <form:label path="lvl_id">
                <spring:message code="label.lvl_id" />
            </form:label>
            </td>
            <td>
            <form:select path="lvl_id" items="${lvlList}">
            </form:select>
            </td>
        </tr>
        <tr>
            <td colspan="2">
            <input type="submit" value="<spring:message code="label.addfood"/>" />
            </td>
        </tr>
    </table>
</form:form>
</body>
</html>

```

So the problem is - when Im trying to add Food using JSP - Foreign Key (lvl\_id) is always null. Tried to change input type in JSP, cascade type in class, replace mappedby with @JoinColumn - no results. Can somebody help me?
Thanks.