WebAttachment.java

/*
 * Copyright 2020 Global Crop Diversity Trust
 *
 * 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.gringlobal.model;

import lombok.Getter;
import lombok.Setter;
import org.genesys.filerepository.model.RepositoryFile;

import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;

/**
 * The Class WebAttachment.
 */
@MappedSuperclass
@Getter
@Setter
public abstract class WebAttachment extends WebOwnedModel implements IAttachment {
	private static final long serialVersionUID = 1L;

	@Column(name = "content_type", length = 100)
	private String contentType;

	@Column(length = 500)
	private String title;

	@Column(name = "virtual_path", nullable = false)
	private String virtualPath;

	@OneToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "repositoryFileId", unique = true)
	private RepositoryFile repositoryFile;

	@Override
	public void lazyLoad() {
		super.lazyLoad();
		lazyLoad(this.repositoryFile);
	}
}