很奇葩的问题

发现一个很奇葩的问题

项目使用hibernate 和spring MVC 开发.

发现改成左边的样子时,tomcat启动时报错,代码如下: 

package com.apidoc.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;

@Entity
@Table(name = "t_api_one")
public class APIOne {
	private int id;
	/***
	 * 接口的访问地址,不包括ip
	 */
	private String url;
	/***
	 * 请求方式:GET,POST,DELETE,PUT
	 */
	private String requestMethod;
	/***
	 * 接口中文名称
	 */
	private String apiName;
	/***
	 * 请求要素
	 */
	private Set<RequestQueryParameter> requestQueryParameters;
	/***
	 * 应答要素
	 */
	private Set<ResponseElement> responseElements;
	/***
	 * 请求的Content-Type
	 */
	private String requestContentType;
	/***
	 * 应答头的Content-Type
	 */
	private String responseContentType;
	private String requestExample;
	private String responseExample;
	/***
	 * 注意事项
	 */
	private String note;
	/***
	 * 预留
	 */
	private String reserved;
	private APIGroup aPIGroup;
	
	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getRequestMethod() {
		return requestMethod;
	}
	public void setRequestMethod(String requestMethod) {
		this.requestMethod = requestMethod;
	}
	public String getApiName() {
		return apiName;
	}
	public void setApiName(String apiName) {
		this.apiName = apiName;
	}
	
	@OneToMany(mappedBy="aPIOne",
			cascade={CascadeType.ALL},
			fetch=FetchType.EAGER)
	@Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
	public Set<RequestQueryParameter> getRequestQueryParameters() {
		return requestQueryParameters;
	}
	public void setRequestQueryParameters(
			Set<RequestQueryParameter> requestQueryParameters) {
		this.requestQueryParameters = requestQueryParameters;
	}
	
	@OneToMany(mappedBy="aPIOne",
			cascade={CascadeType.ALL},
			fetch=FetchType.EAGER)
	@Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
	public Set<ResponseElement> getResponseElements() {
		return responseElements;
	}
	public void setResponseElements(Set<ResponseElement> responseElements) {
		this.responseElements = responseElements;
	}
	public String getRequestContentType() {
		return requestContentType;
	}
	public void setRequestContentType(String requestContentType) {
		this.requestContentType = requestContentType;
	}
	public String getResponseContentType() {
		return responseContentType;
	}
	public void setResponseContentType(String responseContentType) {
		this.responseContentType = responseContentType;
	}
	public String getRequestExample() {
		return requestExample;
	}
	public void setRequestExample(String requestExample) {
		this.requestExample = requestExample;
	}
	public String getResponseExample() {
		return responseExample;
	}
	public void setResponseExample(String responseExample) {
		this.responseExample = responseExample;
	}
	public String getNote() {
		return note;
	}
	public void setNote(String note) {
		this.note = note;
	}
	public String getReserved() {
		return reserved;
	}
	public void setReserved(String reserved) {
		this.reserved = reserved;
	}
	@ManyToOne(cascade = { CascadeType.PERSIST }, fetch = FetchType.EAGER)
	@JoinColumn(name = "api_group_id")
	public APIGroup getaPIGroup() {
		return aPIGroup;
	}
	public void setaPIGroup(APIGroup aPIGroup) {
		this.aPIGroup = aPIGroup;
	}
	
}

猜你喜欢

转载自hw1287789687.iteye.com/blog/2221121