001/* 002 * Copyright (c) 2008, 2009, 2011 Oracle, Inc. All rights reserved. 003 * 004 * This program and the accompanying materials are made available under the 005 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 006 * which accompanies this distribution. The Eclipse Public License is available 007 * at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License 008 * is available at http://www.eclipse.org/org/documents/edl-v10.php. 009 */ 010package javax.persistence; 011 012import java.lang.annotation.Documented; 013import java.lang.annotation.Retention; 014import java.lang.annotation.Target; 015 016import static java.lang.annotation.ElementType.TYPE; 017import static java.lang.annotation.RetentionPolicy.RUNTIME; 018 019/** 020 * Defines a class whose instances are stored as an intrinsic 021 * part of an owning entity and share the identity of the entity. 022 * Each of the persistent properties or fields of the embedded 023 * object is mapped to the database table for the entity. 024 * <p> 025 * <p> Note that the {@link Transient} annotation may be used to 026 * designate the non-persistent state of an embeddable class. 027 * <p> 028 * <pre> 029 * 030 * Example 1: 031 * 032 * @Embeddable public class EmploymentPeriod { 033 * @Temporal(DATE) java.util.Date startDate; 034 * @Temporal(DATE) java.util.Date endDate; 035 * ... 036 * } 037 * 038 * Example 2: 039 * 040 * @Embeddable public class PhoneNumber { 041 * protected String areaCode; 042 * protected String localNumber; 043 * @ManyToOne PhoneServiceProvider provider; 044 * ... 045 * } 046 * 047 * @Entity public class PhoneServiceProvider { 048 * @Id protected String name; 049 * ... 050 * } 051 * 052 * Example 3: 053 * 054 * @Embeddable public class Address { 055 * protected String street; 056 * protected String city; 057 * protected String state; 058 * @Embedded protected Zipcode zipcode; 059 * } 060 * 061 * @Embeddable public class Zipcode { 062 * protected String zip; 063 * protected String plusFour; 064 * } 065 * 066 * 067 * </pre> 068 * 069 * @since Java Persistence 1.0 070 */ 071@Documented 072@Target({TYPE}) 073@Retention(RUNTIME) 074public @interface Embeddable { 075}