title: Embedded Collection within JPA embeddable
body: <p>When there are more than one class(AClass, BClass below) using same @Embeddable class(CClass) which in turn is composed of  an element collection of DClass or any Generic Class such as String.</p>
  
  <p>How can we support such an structure in JPA ? I am getting error when I run.
  Is there an easy way out , there are many classes similar to AClass and Bclass in my system.</p>
  
  <pre><code>@Entity
  public class AClass {
      @Id
      String aid; 
      CClass a;
      String member1;
  }
  
  @Entity
  public class BClass {
      @Id
      String  bid; 
      CClass   a;
      int      member2;
  }
  
  
  @Embeddable
  public class CClass {
      @ElementCollection
      List&lt;DClass&gt; member5;
  }
  
  
  
  @Embeddable
  public class DClass {
      int      member4;
      int      member3;
  }
  </code></pre>
  
  <p>I get below error and only 2 tables are created</p>
  
  <pre><code>&gt; Exception [EclipseLink-4002] (Eclipse Persistence Services -
  &gt; 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException Internal
  &gt; Exception: java.sql.SQLSyntaxErrorException: Column name 'MEMBER3'
  &gt; appears more than once in the CREATE TABLE statement.   Error Code: -1
  &gt; Call: CREATE TABLE AClass_MEMBER5 (MEMBER3 INTEGER, MEMBER4 INTEGER,
  &gt; AClass_AID VARCHAR(255), MEMBER3 INTEGER, MEMBER4 INTEGER, AClass_AID
  &gt; VARCHAR(255)) Query: DataModifyQuery(sql="CREATE TABLE AClass_MEMBER5
  &gt; (MEMBER3 INTEGER, MEMBER4 INTEGER, AClass_AID VARCHAR(255), MEMBER3
  &gt; INTEGER, MEMBER4 INTEGER, AClass_AID VARCHAR(255))")  at
  &gt; org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
  &gt;   at
  &gt; org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:679)
  &gt;   at
  &gt; org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)
  &gt;   at
  &gt; org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1995)
  &gt;   at
  &gt; org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:570)
  &gt;   at
  &gt; org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:242)
  &gt;   at
  &gt; org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
  &gt;   at
  &gt; org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:271)
  &gt;   at
  &gt; org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:251)
  &gt;   at
  &gt; org.eclipse.persistence.queries.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:85)
  &gt;   at
  &gt; org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
  &gt;   at
  &gt; org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3207)
  &gt;   at
  &gt; org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
  &gt;   at
  &gt; org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
  &gt;   at
  &gt; org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1730)
  &gt;   at
  &gt; org.eclipse.persistence.internal.sessions.AbstractSession.priviledgedExecuteNonSelectingCall(AbstractSession.java:5000)
  &gt;   at
  &gt; org.eclipse.persistence.tools.schemaframework.DatabaseObjectDefinition.createOnDatabase(DatabaseObjectDefinition.java:141)
  &gt;   at
  &gt; org.eclipse.persistence.tools.schemaframework.SchemaManager.createObject(SchemaManager.java:223)
  &gt;   at
  &gt; org.eclipse.persistence.tools.schemaframework.TableCreator.createTables(TableCreator.java:165)
  &gt;   at
  &gt; org.eclipse.persistence.tools.schemaframework.TableCreator.createTables(TableCreator.java:142)
  &gt;   at
  &gt; org.eclipse.persistence.tools.schemaframework.TableCreator.createTables(TableCreator.java:134)
  &gt;   at
  &gt; org.eclipse.persistence.tools.schemaframework.SchemaManager.createDefaultTables(SchemaManager.java:1032)
  &gt;   at
  &gt; org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.generateDefaultTables(EntityManagerFactoryProvider.java:102)
  &gt;   at
  &gt; org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDLToDatabase(EntityManagerSetupImpl.java:3937)
  &gt;   at
  &gt; org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeMetadataDDLToDatabase(EntityManagerSetupImpl.java:3992)
  &gt;   at
  &gt; org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDL(EntityManagerSetupImpl.java:3903)
  &gt;   at
  &gt; org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDL(EntityManagerSetupImpl.java:3776)
  &gt;   at
  &gt; org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:724)
  &gt;   at
  &gt; org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
  &gt;   at
  &gt; org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:182)
  &gt;   at
  &gt; org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:527)
  &gt;   at
  &gt; org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:358)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:199)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.PersistenceUnitLoader.&lt;init&gt;(PersistenceUnitLoader.java:107)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:223)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:230)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
  &gt;   at
  &gt; com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:922)
  &gt;   at
  &gt; com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:431)
  &gt;   at
  &gt; com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
  &gt;   at
  &gt; org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:537)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
  &gt;   at
  &gt; org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:131)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
  &gt;   at java.security.AccessController.doPrivileged(Native Method)   at
  &gt; javax.security.auth.Subject.doAs(Subject.java:356)    at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
  &gt;   at
  &gt; org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297)
  &gt;   at
  &gt; com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)
  &gt;   at
  &gt; org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
  &gt;   at
  &gt; org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
  &gt;   at
  &gt; org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
  &gt;   at
  &gt; org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
  &gt;   at
  &gt; org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
  &gt;   at
  &gt; org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
  &gt;   at
  &gt; org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
  &gt;   at
  &gt; org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
  &gt;   at
  &gt; org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
  &gt;   at
  &gt; org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
  &gt;   at
  &gt; org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
  &gt;   at
  &gt; org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
  &gt;   at
  &gt; org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
  &gt;   at
  &gt; org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
  &gt;   at
  &gt; org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
  &gt;   at
  &gt; org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
  &gt;   at java.lang.Thread.run(Thread.java:724) Caused by:
  &gt; java.sql.SQLSyntaxErrorException: Column name 'MEMBER3' appears more
  &gt; than once in the CREATE TABLE statement.      at
  &gt; org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown
  &gt; Source)   at
  &gt; org.apache.derby.client.am.SqlException.getSQLException(Unknown
  &gt; Source)   at
  &gt; org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
  &gt;   at
  &gt; com.sun.gjc.spi.base.ConnectionHolder.prepareStatement(ConnectionHolder.java:586)
  &gt;   at
  &gt; com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareCachedStatement(ConnectionWrapper40.java:255)
  &gt;   at
  &gt; com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareCachedStatement(ConnectionWrapper40.java:52)
  &gt;   at
  &gt; com.sun.gjc.spi.ManagedConnectionImpl.prepareCachedStatement(ManagedConnectionImpl.java:992)
  &gt;   at
  &gt; com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareStatement(ConnectionWrapper40.java:173)
  &gt;   at
  &gt; org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1551)
  &gt;   at
  &gt; org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1500)
  &gt;   at
  &gt; org.eclipse.persistence.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:778)
  &gt;   at
  &gt; org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:619)
  &gt;   ... 78 more Caused by: org.apache.derby.client.am.SqlException:
  &gt; Column name 'MEMBER3' appears more than once in the CREATE TABLE
  &gt; statement.    at
  &gt; org.apache.derby.client.am.Statement.completeSqlca(Unknown Source)    at
  &gt; org.apache.derby.client.net.NetStatementReply.parsePrepareError(Unknown
  &gt; Source)   at
  &gt; org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(Unknown
  &gt; Source)   at
  &gt; org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown
  &gt; Source)   at
  &gt; org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown
  &gt; Source)   at
  &gt; org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown
  &gt; Source)   at
  &gt; org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown
  &gt; Source)   at
  &gt; org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown
  &gt; Source)   at
  &gt; org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown
  &gt; Source)   at
  &gt; org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
  &gt;   at org.apache.derby.client.am.Connection.prepareStatementX(Unknown
  &gt; Source)   ... 88 more
  </code></pre>