Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #32115 > unrolled thread
| Started by | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| First post | 2015-07-24 17:05 +0200 |
| Last post | 2015-08-03 15:43 -0700 |
| Articles | 17 — 7 participants |
Back to article view | Back to comp.lang.java.programmer
From JDBC to JPA Cecil Westerhof <Cecil@decebal.nl> - 2015-07-24 17:05 +0200
Re: From JDBC to JPA Eternal Hope <laughingspam99@gmail.com> - 2015-07-24 17:53 +0100
Re: From JDBC to JPA Cecil Westerhof <Cecil@decebal.nl> - 2015-07-24 22:03 +0200
Re: From JDBC to JPA Eternal Hope <laughingspam99@gmail.com> - 2015-07-25 05:23 +0100
Re: From JDBC to JPA Cecil Westerhof <Cecil@decebal.nl> - 2015-07-25 10:37 +0200
Re: From JDBC to JPA Arne Vajhøj <arne@vajhoej.dk> - 2015-07-25 23:45 -0400
Re: From JDBC to JPA Fredrik Jonson <fredrik@jonson.org> - 2015-07-25 08:12 +0000
Re: From JDBC to JPA Arne Vajhøj <arne@vajhoej.dk> - 2015-07-25 23:49 -0400
Re: From JDBC to JPA Arne Vajhøj <arne@vajhoej.dk> - 2015-07-25 23:38 -0400
Re: From JDBC to JPA Joerg Meier <joergmmeier@arcor.de> - 2015-07-24 20:40 +0200
Re: From JDBC to JPA Jeff Higgins <jeff@invalid.invalid> - 2015-07-24 15:45 -0400
Re: From JDBC to JPA Cecil Westerhof <Cecil@decebal.nl> - 2015-07-24 22:32 +0200
Re: From JDBC to JPA Joerg Meier <joergmmeier@arcor.de> - 2015-07-24 22:32 +0200
Re: From JDBC to JPA Cecil Westerhof <Cecil@decebal.nl> - 2015-07-24 23:18 +0200
Re: From JDBC to JPA Arne Vajhøj <arne@vajhoej.dk> - 2015-07-25 14:40 -0400
Re: From JDBC to JPA Arne Vajhøj <arne@vajhoej.dk> - 2015-07-25 23:53 -0400
Re: From JDBC to JPA Lew <lewbloch@gmail.com> - 2015-08-03 15:43 -0700
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2015-07-24 17:05 +0200 |
| Subject | From JDBC to JPA |
| Message-ID | <87380doatw.fsf@Equus.decebal.nl> |
I need to change the use of JDBC to JPA in a range of applications. I am new to JPA. Anyone good tips or links on how to accomplish this? Until now I did not find anything very useful with Google. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof
[toc] | [next] | [standalone]
| From | Eternal Hope <laughingspam99@gmail.com> |
|---|---|
| Date | 2015-07-24 17:53 +0100 |
| Message-ID | <motqel$lmt$1@dont-email.me> |
| In reply to | #32115 |
On 24/07/2015 16:05, Cecil Westerhof wrote: > I need to change the use of JDBC to JPA in a range of applications. I > am new to JPA. Anyone good tips or links on how to accomplish this? > Until now I did not find anything very useful with Google. http://openjpa.apache.org/ http://openjpa.apache.org/builds/2.4.0/apache-openjpa/docs/manual.pdf Is about the best documentation I have found to date. Rather you than me. -- Laughing Spam Fritter
[toc] | [prev] | [next] | [standalone]
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2015-07-24 22:03 +0200 |
| Message-ID | <87y4i5mig2.fsf@Equus.decebal.nl> |
| In reply to | #32117 |
On Friday 24 Jul 2015 18:53 CEST, Eternal Hope wrote: > On 24/07/2015 16:05, Cecil Westerhof wrote: >> I need to change the use of JDBC to JPA in a range of applications. >> I am new to JPA. Anyone good tips or links on how to accomplish >> this? Until now I did not find anything very useful with Google. > > http://openjpa.apache.org/ > > http://openjpa.apache.org/builds/2.4.0/apache-openjpa/docs/manual.pdf That the best documentation is for a certain implementation and not from JPA is a bad omen. :'-( I need to write clean JPA code, because it should be possible two switch from Hubernate, to openJPA, to … in a moments notice. > Is about the best documentation I have found to date. > > Rather you than me. You are confirming my fears. ;-) -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof
[toc] | [prev] | [next] | [standalone]
| From | Eternal Hope <laughingspam99@gmail.com> |
|---|---|
| Date | 2015-07-25 05:23 +0100 |
| Message-ID | <mov2s3$n8g$1@dont-email.me> |
| In reply to | #32126 |
On 24/07/2015 21:03, Cecil Westerhof wrote: > On Friday 24 Jul 2015 18:53 CEST, Eternal Hope wrote: > >> On 24/07/2015 16:05, Cecil Westerhof wrote: >>> I need to change the use of JDBC to JPA in a range of applications. >>> I am new to JPA. Anyone good tips or links on how to accomplish >>> this? Until now I did not find anything very useful with Google. >> >> http://openjpa.apache.org/ >> >> http://openjpa.apache.org/builds/2.4.0/apache-openjpa/docs/manual.pdf > > That the best documentation is for a certain implementation and not > from JPA is a bad omen. :'-( Not sure what you mean by 'from JPA' JPA is a specification currently 'owned and maintained' by Larry and his pals. Try http://www.oracle.com/technetwork/java/javaee/tech/persistence-jsp-140049.html Although I have to admit that I find the oracle documentation a litte dense sometimes. Check out https://www.jcp.org/en/jsr/detail?id=220 if you want to fry your brain -- Laughing Spam Fritter
[toc] | [prev] | [next] | [standalone]
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2015-07-25 10:37 +0200 |
| Message-ID | <87oaj0vdj9.fsf@Equus.decebal.nl> |
| In reply to | #32134 |
On Saturday 25 Jul 2015 06:23 CEST, Eternal Hope wrote: > On 24/07/2015 21:03, Cecil Westerhof wrote: >> On Friday 24 Jul 2015 18:53 CEST, Eternal Hope wrote: >> >>> On 24/07/2015 16:05, Cecil Westerhof wrote: >>>> I need to change the use of JDBC to JPA in a range of >>>> applications. I am new to JPA. Anyone good tips or links on how >>>> to accomplish this? Until now I did not find anything very useful >>>> with Google. >>> >>> http://openjpa.apache.org/ >>> >>> http://openjpa.apache.org/builds/2.4.0/apache-openjpa/docs/manual.pdf >> >> That the best documentation is for a certain implementation and not >> from JPA is a bad omen. :'-( > > Not sure what you mean by 'from JPA' JPA is a specification > currently 'owned and maintained' by Larry and his pals. I mend that when I am told to read the openJPA documentation instead of the JPA documentation that I find this not a good sign. > Try > http://www.oracle.com/technetwork/java/javaee/tech/persistence-jsp-140049.html > > Although I have to admit that I find the oracle documentation a > litte dense sometimes. > > Check out https://www.jcp.org/en/jsr/detail?id=220 if you want to > fry your brain I will add your links also. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2015-07-25 23:45 -0400 |
| Message-ID | <mp1l5m$3p9$1@speranza.aioe.org> |
| In reply to | #32136 |
On 7/25/2015 4:37 AM, Cecil Westerhof wrote: > On Saturday 25 Jul 2015 06:23 CEST, Eternal Hope wrote: > >> On 24/07/2015 21:03, Cecil Westerhof wrote: >>> On Friday 24 Jul 2015 18:53 CEST, Eternal Hope wrote: >>> >>>> On 24/07/2015 16:05, Cecil Westerhof wrote: >>>>> I need to change the use of JDBC to JPA in a range of >>>>> applications. I am new to JPA. Anyone good tips or links on how >>>>> to accomplish this? Until now I did not find anything very useful >>>>> with Google. >>>> >>>> http://openjpa.apache.org/ >>>> >>>> http://openjpa.apache.org/builds/2.4.0/apache-openjpa/docs/manual.pdf >>> >>> That the best documentation is for a certain implementation and not >>> from JPA is a bad omen. :'-( >> >> Not sure what you mean by 'from JPA' JPA is a specification >> currently 'owned and maintained' by Larry and his pals. > > I mend that when I am told to read the openJPA documentation instead > of the JPA documentation that I find this not a good sign. Don't worry. It quite common that: - the official specification of the standard is hard to read - most people prefer to read: - documentation for a specific implementation - third party tutorials My guess is that you did not learn Java from reading the JLS but instead read either the Java tutorial (from one particular Java vendor!) or bought a few books. :-) If that OpenJPA documentation is good then it will clearly explain what is standard and maybe provide a few implementation specific extras. Arne
[toc] | [prev] | [next] | [standalone]
| From | Fredrik Jonson <fredrik@jonson.org> |
|---|---|
| Date | 2015-07-25 08:12 +0000 |
| Message-ID | <slrnmr6h6k.7mm.fredrik@biggles.jonson.org> |
| In reply to | #32126 |
In <87y4i5mig2.fsf@Equus.decebal.nl> Cecil Westerhof wrote: > I need to write clean JPA code, because it should be possible two switch > from Hibernate to openJPA in a moments notice. That is a requirement that is not as easy to fulfill as is appears on first sight. Especially for someone who does not have experience with JPA already. I think you'll find that each JPA implementation has its own set of quirks in performance as well as in configuration. And since you're combining it with a database, you'll have your database provider's quirks to consider too. A more reasonable goal is to use only standard JPA annotations for the beans and most queries, and otherwise aim to limit the provider specific stuff to parts of the code that you design to be rather easily replaceable when you decide to try to migrate to another provider. That said, you can get quite far with plain JPA, at least as long as your database model isn't too complex. Not to say that JPA is special in this way. Almost every standard that have multiple implementations also have quirks that are specific to each implementation. The common case is obviously usually better covered and more similar between implementations. On a related theme: Do not be afraid to use native queries when building more complex queries. There's nothing wrong with JQL, but you do not have the same control over the details compared to plain SQL. -- Fredrik Jonson
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2015-07-25 23:49 -0400 |
| Message-ID | <mp1lbf$402$1@speranza.aioe.org> |
| In reply to | #32135 |
On 7/25/2015 4:12 AM, Fredrik Jonson wrote: > In <87y4i5mig2.fsf@Equus.decebal.nl> Cecil Westerhof wrote: > >> I need to write clean JPA code, because it should be possible two switch >> from Hibernate to openJPA in a moments notice. > > That is a requirement that is not as easy to fulfill as is appears on first > sight. Especially for someone who does not have experience with JPA already. > > I think you'll find that each JPA implementation has its own set of quirks in > performance as well as in configuration. And since you're combining it with a > database, you'll have your database provider's quirks to consider too. > > A more reasonable goal is to use only standard JPA annotations for the beans > and most queries, and otherwise aim to limit the provider specific stuff to > parts of the code that you design to be rather easily replaceable when you > decide to try to migrate to another provider. That said, you can get quite far > with plain JPA, at least as long as your database model isn't too complex. > > Not to say that JPA is special in this way. Almost every standard that have > multiple implementations also have quirks that are specific to each > implementation. The common case is obviously usually better covered and more > similar between implementations. > > On a related theme: Do not be afraid to use native queries when building more > complex queries. There's nothing wrong with JQL, but you do not have the same > control over the details compared to plain SQL. It is my impression that a lot of people (maybe the large majority of people) are able to do with only standard JPA code - maybe with a small dose of standard SQL where necessary. Arne
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2015-07-25 23:38 -0400 |
| Message-ID | <mp1ko5$35j$1@speranza.aioe.org> |
| In reply to | #32126 |
On 7/24/2015 4:03 PM, Cecil Westerhof wrote: > On Friday 24 Jul 2015 18:53 CEST, Eternal Hope wrote: >> On 24/07/2015 16:05, Cecil Westerhof wrote: >>> I need to change the use of JDBC to JPA in a range of applications. >>> I am new to JPA. Anyone good tips or links on how to accomplish >>> this? Until now I did not find anything very useful with Google. >> >> http://openjpa.apache.org/ >> >> http://openjpa.apache.org/builds/2.4.0/apache-openjpa/docs/manual.pdf > > That the best documentation is for a certain implementation and not > from JPA is a bad omen. :'-( > > I need to write clean JPA code, because it should be possible two > switch from Hubernate, to openJPA, to … in a moments notice. Just use the JPA API and not anything from implementation API and you should be on the right track. Arne
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2015-07-24 20:40 +0200 |
| Message-ID | <mkkvfiue371s$.exxqwvel00ge.dlg@40tude.net> |
| In reply to | #32115 |
On Fri, 24 Jul 2015 17:05:15 +0200, Cecil Westerhof wrote: > I need to change the use of JDBC to JPA in a range of applications. I > am new to JPA. Anyone good tips or links on how to accomplish this? > Until now I did not find anything very useful with Google. One tip: there are multiple (I think Eclipselink, Hibernate, some 3rd party) tools to generate JPA-Annotated .java files from your database schema. That alone tends to end up a huge time saver. Liebe Gruesse, Joerg -- Ich lese meine Emails nicht, replies to Email bleiben also leider ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Date | 2015-07-24 15:45 -0400 |
| Message-ID | <mou4pj$ud5$1@dont-email.me> |
| In reply to | #32115 |
On 07/24/2015 11:05 AM, Cecil Westerhof wrote: > I need to change the use of JDBC to JPA in a range of applications. I > am new to JPA. Anyone good tips or links on how to accomplish this? > Until now I did not find anything very useful with Google. > Maybe this is not one of the not very useful articles you've found. Migrating JDBC Data Access Objects to use EJB3 <http://www.theserverside.com/news/1364373/Migrating-JDBC-Data-Access-Objects-to-use-EJB3>
[toc] | [prev] | [next] | [standalone]
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2015-07-24 22:32 +0200 |
| Message-ID | <87pp3hmh3m.fsf@Equus.decebal.nl> |
| In reply to | #32125 |
On Friday 24 Jul 2015 21:45 CEST, Jeff Higgins wrote: > On 07/24/2015 11:05 AM, Cecil Westerhof wrote: >> I need to change the use of JDBC to JPA in a range of applications. >> I am new to JPA. Anyone good tips or links on how to accomplish >> this? Until now I did not find anything very useful with Google. >> > Maybe this is not one of the not very useful articles you've found. > Migrating JDBC Data Access Objects to use EJB3 > <http://www.theserverside.com/news/1364373/Migrating-JDBC-Data-Access-Objects-to-use-EJB3> No, it was not. I put it on my list. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2015-07-24 22:32 +0200 |
| Message-ID | <1cqa5k3y9ana7$.i9l3lme0degd.dlg@40tude.net> |
| In reply to | #32115 |
On Fri, 24 Jul 2015 17:05:15 +0200, Cecil Westerhof wrote: > I need to change the use of JDBC to JPA in a range of applications. I > am new to JPA. Anyone good tips or links on how to accomplish this? > Until now I did not find anything very useful with Google. <http://stackoverflow.com/questions/6033905/create-the-perfect-jpa-entity> May also be a good read for you. Liebe Gruesse, Joerg -- Ich lese meine Emails nicht, replies to Email bleiben also leider ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2015-07-24 23:18 +0200 |
| Message-ID | <87h9otmeza.fsf@Equus.decebal.nl> |
| In reply to | #32127 |
On Friday 24 Jul 2015 22:32 CEST, Joerg Meier wrote: > On Fri, 24 Jul 2015 17:05:15 +0200, Cecil Westerhof wrote: > >> I need to change the use of JDBC to JPA in a range of applications. >> I am new to JPA. Anyone good tips or links on how to accomplish >> this? Until now I did not find anything very useful with Google. > > <http://stackoverflow.com/questions/6033905/create-the-perfect-jpa-entity> > > May also be a good read for you. I have something to do this weekend. ;-) -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2015-07-25 14:40 -0400 |
| Message-ID | <mp0l79$96j$1@speranza.aioe.org> |
| In reply to | #32115 |
On 7/24/2015 11:05 AM, Cecil Westerhof wrote: > I need to change the use of JDBC to JPA in a range of applications. I > am new to JPA. Anyone good tips or links on how to accomplish this? > Until now I did not find anything very useful with Google. Google of JPA tutorial did not provide anything useful? There are a lot of tutorials out there. Arne
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2015-07-25 23:53 -0400 |
| Message-ID | <mp1lk3$4bj$1@speranza.aioe.org> |
| In reply to | #32140 |
On 7/25/2015 2:40 PM, Arne Vajhøj wrote: > On 7/24/2015 11:05 AM, Cecil Westerhof wrote: >> I need to change the use of JDBC to JPA in a range of applications. I >> am new to JPA. Anyone good tips or links on how to accomplish this? >> Until now I did not find anything very useful with Google. > > Google of JPA tutorial did not provide anything useful? > > There are a lot of tutorials out there. A few random: https://docs.oracle.com/javaee/7/tutorial/partpersist.htm http://www.tutorialspoint.com/jpa/index.htm http://www.vogella.com/tutorials/JavaPersistenceAPI/article.html http://www.javaworld.com/article/2077817/java-se/understanding-jpa-part-1-the-object-oriented-paradigm-of-data-persistence.html Arne
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2015-08-03 15:43 -0700 |
| Message-ID | <f9c0d147-9d87-4af2-8832-72f0ff80fa67@googlegroups.com> |
| In reply to | #32145 |
Cecil Westerhof wrote: > >> I need to change the use of JDBC to JPA in a range of applications. I > >> am new to JPA. Anyone good tips or links on how to accomplish this? > >> Until now I did not find anything very useful with Google. JPA is not a replacement for JDBC generally. You use JDBC when you think of a persistent store as a set of data tables. You use JPA when you think of persistent objects. The ontologies differ. JDBC you don't have 'EntityManager', you have transactions, you have artificial ID fields declared as "INTEGER", you have rows and columns. JPA you have objects in a managed state, that own relationships to other object types. (Not relations!) You don't want or use a DAO approach. You shouldn't ever link objects via an ID field, or even expose it in the model. Good luck. To the degree that you use JPA fro a data mindset instead of an object one, you will be screwed. -- Lew
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web