Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6801577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:07:02+00:00 2026-05-26T19:07:02+00:00

SOLUTION : I have figured out a work around for this problem. I ran

  • 0

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

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.

enter image description here

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:07:02+00:00Added an answer on May 26, 2026 at 7:07 pm

    The issue you are currently having is pointed out in the lines of exception below:

    at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:560)
        ... 1 more
    Caused by: java.lang.IllegalArgumentException
        at nu.MedicalLaboratory.pcProvideField(MedicalLaboratory.java)
    

    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?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a weird problem that i can't figure out a solution for: I've
I can't seem to figure this one out. I have a validator-type script that
I have a wierd problem that i need to work out how to resolve,
I searched around and couldn't find a solution to this problem. I am trying
I have been trying to figure out a solution but nothing has really presented
I am using NHibernate as my ORM solution and have a need for a
When using ASP.net webforms my usual solution would have following type of setup -
My answer: After getting annoyed, I have found a solution. The problem was indeed
I am playing around with The Enterprise Library Validation Block. I have a class
First of all, I'm using Rails3 with Ruby 1.9.2. I have a problem using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.