| /** |
| * Copyright (C) - Loetz GmbH&Co.KG, 69115 Heidelberg, Germany |
| * |
| * This source was created by OSBP Softwarefactory Wizard! |
| * |
| * OSBP is (C) - Loetz GmbH&Co.KG, 69115 Heidelberg, Germany |
| * |
| * ================================================================ |
| * |
| * @file $HeadURL$ |
| * @version $Revision$ |
| * @date $Date$ |
| * @author $Author$ |
| */ |
| package org.osbp.mysmartshop.entities; |
| |
| import javax.persistence.Entity; |
| import javax.persistence.FetchType; |
| import javax.persistence.JoinColumn; |
| import javax.persistence.ManyToOne; |
| import javax.persistence.Table; |
| import org.eclipse.osbp.dsl.common.datatypes.IEntity; |
| import org.eclipse.osbp.runtime.common.annotations.Dispose; |
| import org.osbp.mysmartshop.entities.BaseUUID; |
| import org.osbp.mysmartshop.entities.DtoTestParent; |
| |
| @Entity |
| @Table(name = "DTO_TEST_CHILD_CROSS_REF") |
| @SuppressWarnings("all") |
| public class DtoTestChildCrossRef extends BaseUUID implements IEntity { |
| @ManyToOne(fetch = FetchType.LAZY) |
| @JoinColumn(name = "CONTAINER_ID") |
| private DtoTestParent container; |
| |
| /** |
| * Checks whether the object is disposed. |
| * @throws RuntimeException if the object is disposed. |
| */ |
| private void checkDisposed() { |
| if (isDisposed()) { |
| throw new RuntimeException("Object already disposed: " + this); |
| } |
| } |
| |
| /** |
| * Calling dispose will destroy that instance. The internal state will be |
| * set to 'disposed' and methods of that object must not be used anymore. |
| * Each call will result in runtime exceptions.<br> |
| * If this object keeps composition containments, these will be disposed too. |
| * So the whole composition containment tree will be disposed on calling this method. |
| */ |
| @Dispose |
| public void dispose() { |
| if (isDisposed()) { |
| return; |
| } |
| super.dispose(); |
| } |
| |
| /** |
| * @return Returns the container property or <code>null</code> if not present. |
| */ |
| public DtoTestParent getContainer() { |
| checkDisposed(); |
| return this.container; |
| } |
| |
| /** |
| * Sets the container property to this instance. |
| * Since the reference is a container reference, the opposite reference (DtoTestParent.crossRefChilds) |
| * of the container will be handled automatically and no further coding is required to keep them in sync. |
| * See {@link DtoTestParent#setCrossRefChilds(DtoTestParent)}. |
| */ |
| public void setContainer(final DtoTestParent container) { |
| checkDisposed(); |
| if (this.container != null) { |
| this.container.internalRemoveFromCrossRefChilds(this); |
| } |
| this.container = container; |
| if (this.container != null) { |
| this.container.internalAddToCrossRefChilds(this); |
| } |
| |
| } |
| } |