SOLUTION :
I have figured out a work around for this problem. I ran my main class using a shell script and I also enhanced all my classes using the same shell script here is the code.
#!/bin/sh
#
# Compile and Run the OpenJPA test program
#
cp=.
cp=$cp:lib/mysql-connector-java.jar
cp=$cp:lib/openjpa-2.0.1.jar
cp=$cp:lib/commons-lang-2.1.jar
cp=$cp:lib/geronimo-jta_1.1_spec-1.1.1.jar
cp=$cp:lib/serp-1.13.1.jar
cp=$cp:lib/commons-collections-3.2.1.jar
cp=$cp:lib/geronimo-jpa_2.0_spec-1.1.jar
#
echo "Compiling"
javac -cp $cp *.java */*.java
echo "Enhancing"
java -cp $cp org.apache.openjpa.enhance.PCEnhancer nu/InstrumentType.java nu/Instrument.java nu/Laboratory.java nu/MedicalLaboratory.java
echo "Running"
java -cp $cp test
As you can see nu is my package name and my class that needs to be enhanced is followed by /
test is my main class.
I dont know but enhancing this way instead of using ecplise built in enhancer works.
QUESTION :
This is my file layer hierarchy

I am using openjpa
Instrument , InstrumentType, Laboratory, MedicalLaboratory are my classes.
I have created joined tables/referenced tables inside my Instrument class and InstrumentType class which is not getting created.
I have the following code inside my Instrument class
@ManyToOne
@JoinColumn(name="type", nullable=false)
public InstrumentType type;
@ManyToMany(fetch=EAGER)
@JoinTable(name="usedBy",
joinColumns=@JoinColumn(name="instrument"),
inverseJoinColumns=@JoinColumn(name="laboratory"))
public Set<Laboratory> UsedBy;
public void setUsedBy(Set<Laboratory> UsedBy) {
this.UsedBy = UsedBy;
}
I have the following code inside my InstrumentType class
@ElementCollection(fetch=EAGER)
@Column(name="name")
@CollectionTable(name="InstrumentName", joinColumns=@JoinColumn(name="type"))
public Set<String> names;
This is the output ie the tables that I am able to see in my Navicat. As you can see only the 4 tables are getting created and not the joined tables.

This is my main class
public class main {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
// Create the new objects to be persisted.
Instrument i = new Instrument();
InstrumentType it = new InstrumentType();
Laboratory l = new Laboratory();
MedicalLaboratory ml = new MedicalLaboratory();
// Configure and create the factory.
java.util.Map<Object,Object> map = new java.util.HashMap<Object,Object>();
map.put("openjpa.ConnectionUserName", "root");
map.put("openjpa.ConnectionPassword", "root");
map.put("openjpa.ConnectionURL", "jdbc:mysql://127.0.0.1:3306/test123");
map.put("openjpa.ConnectionDriverName", "com.mysql.jdbc.Driver");
map.put("openjpa.jdbc.SynchronizeMappings", "buildSchema");
EntityManagerFactory factory = Persistence.createEntityManagerFactory("test123", map);
// Create a new EntityManager from the EntityManagerFactory. The
// EntityManager is the main object in the persistence API, and is
// used to create, delete, and query objects, as well as access
// the current transaction
EntityManager em = factory.createEntityManager();
// Begin a new local transaction so that we can persist a new entity
em.getTransaction().begin();
// Create and persist a new Message entity
em.persist(i);
em.persist(it);
em.persist(l);
em.persist(ml);
// Commit the transaction, which will cause the entity to
// be stored in the database
em.getTransaction().commit();
// It is always good practice to close the EntityManager so that
// resources are conserved.
em.close();
factory.close();
}
}
This is the error I am getting not able to understand it.
73 test123 INFO [main] openjpa.Runtime - Starting OpenJPA 2.0.1
164 test123 INFO [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary".
Exception in thread "main" <openjpa-2.0.1-r422266:989424 fatal store error> org.apache.openjpa.persistence.RollbackException: null
at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:584)
at nu.main.main(main.java:50)
Caused by: <openjpa-2.0.1-r422266:989424 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: null
at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1963)
at org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1479)
at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:925)
at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:560)
... 1 more
Caused by: java.lang.IllegalArgumentException
at nu.MedicalLaboratory.pcProvideField(MedicalLaboratory.java)
at org.apache.openjpa.kernel.StateManagerImpl.provideField(StateManagerImpl.java:3135)
at org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2956)
at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:40)
at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:1047)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2077)
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2037)
at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1955)
... 5 more
I am just trying to get the joined tables to be displayed so that I can query on them. It would be great if anyone can point out why the joined tables are not getting created.
The issue you are currently having is pointed out in the lines of exception below:
Can you post the full mapping classes you have, also, what are the Entity Relationships you are trying to map? you should probably build one ER class first, with no ER fields, then choose the ‘simplest’ ER relationship, and map that next. Its not clear from your listings, what is being mapped?