Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've figured out how to do it - using <a href="https://code.google.com/p/odata4j/" rel="nofollow noreferrer">odata4j</a>. I've documented my steps below in case anyone else wants to do something similar.</p> <p>You will need to:</p> <ul> <li>generate a JPA model from your database</li> <li>use odata4j's NorthwindJpaProducerExample.java script</li> </ul> <p>Detailed steps are below:</p> <ol> <li>Odata4j is an open-source Odata Producer/Consumer in Java. Therefore, you will need to <strong>set up Eclipse for EE Developers with a database</strong>. I suggest <a href="http://www.youtube.com/watch?annotation_id=annotation_644392&amp;feature=iv&amp;src_vid=R7B5T3H2I5A&amp;v=UQJKkqqiVDo" rel="nofollow noreferrer">this</a> tutorial if you are new to Eclipse. </li> <li>Follow <a href="http://publib.boulder.ibm.com/infocenter/radhelp/v8/index.jsp?topic=/com.ibm.rad.samptut.doc/tutorials/javaee/topics/lesson1.4.html" rel="nofollow noreferrer">these</a> instructions to generate a JPA model.</li> <li>Go to Odata4j and download the latest archive zip</li> <li>Add odata4j-bundle-x.x.jar to your build path (it is found in the bundles file).</li> <li>Insert the following scripts from Odata4j, found on their github: NorthwindJpaProducerExample, JPAProvider, and DatabaseUtils (requires <a href="http://www.slf4j.org/" rel="nofollow noreferrer">slf4j</a>). (To be honest, I just copy and pasted them into Eclipse). At this point, your Project Explorer bar should look like this (without model.main):</li> </ol> <p><img src="https://i.stack.imgur.com/XoEMb.png" alt="Project Explorer Bar"></p> <p>At this point, right-click the project and select Build Path > Configure Build Path. Add the following "External Jars" from your Odata4j archive file.</p> <p><img src="https://i.stack.imgur.com/kei0J.png" alt="External Jars"></p> <p>Now edit the code in NorthwindJpaProducerExample in the following ways:</p> <ol> <li>Change the string "endpointUri" to whatever url you want the oData at</li> <li>Change the string "persistenceUnitName" to the name of your entity in persistence.xml (as you can in the image above, mine was called "createJPA".)</li> </ol> <p><img src="https://i.stack.imgur.com/bMuK8.png" alt="code sample in NorthwindJpaProducerExample"></p> <p>And then you have OData!</p> <p><img src="https://i.stack.imgur.com/fECTk.png" alt="My OData"></p> <p>I ran in to a couple problems while following these steps and will document them here in case you have them also.</p> <ul> <li>In order to successfully follow step 2 (generate JPA) each table MUST have a primary key. Do it - I'm not joking. </li> <li>After editing the code, I had a "BigInteger" error. JPAProducer does not support bigInteger field types. Go back to your database and change the size of your column to a regular int.</li> <li>After changing your database in ANY manner, make sure to refresh you database and to clean the project. This will make you and Eclipse happy.</li> <li>I don't think this will be necessary for everyone, but I did need to add a HyperSQL driver dependency. If you get a HSQL error, go to <a href="http://sourceforge.net/projects/hsqldb/files/hsqldb/" rel="nofollow noreferrer">here</a> and get the latest stable version. Add the hsqldb.jar to your Build Path.</li> </ul> <p>Not SUPER easy, but a lot better than a 70+ page manual.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload