RE: [External] Re: OpenJPA Null Update
Hello, I think that Chapter 12.1.2 in the Manual will help here. When attaching null fields in these cases, OpenJPA cannot distinguish between a field that was unloaded and one that was intentionally set to null. In this case, OpenJPA will use the current detach state setting to determine how to handle null fields: fields that would have been included in the detached state are treated as loaded, and will in turn set the corresponding attached field to null. Regards, John -Original Message- From: Tibebu, Nebiyou [USA] [mailto:tibebu_nebi...@bah.com] Sent: Friday, June 14, 2013 5:26 AM To: users@openjpa.apache.org Subject: RE: [External] Re: OpenJPA Null Update Rick, Thank you for your help. Here is the scenario: 1. Get a persistent instance of an entity 2. Detach entity 3. Update values on the entity with non-null values 4. One of these values will be a string value with existing non-trivial data 5. Set the value on this field to null 6. Merge entity 7. All other fields are updated except this value. Nebiyou Tibebu Booz | Allen | Hamilton 8283 Greensboro Dr, Mclean, VA 22102 tibebu_nebi...@bah.com From: Rick Curtis [curti...@gmail.com] Sent: Thursday, June 13, 2013 10:31 PM To: users@openjpa.apache.org Subject: RE: [External] Re: OpenJPA Null Update Well, you are going to have to describe what your scenario is for any of us to help you out. On Jun 13, 2013 6:57 PM, Tibebu, Nebiyou [USA] tibebu_nebi...@bah.com wrote: I am not getting any errors. It is just being ignored. Nebiyou Tibebu Booz | Allen | Hamilton 8283 Greensboro Dr, Mclean, VA 22102 tibebu_nebi...@bah.com From: Tibebu, Nebiyou [USA] Sent: Thursday, June 13, 2013 5:55 PM To: users@openjpa.apache.org Subject: RE: [External] Re: OpenJPA Null Update Nebiyou Tibebu Booz | Allen | Hamilton 8283 Greensboro Dr, Mclean, VA 22102 tibebu_nebi...@bah.com From: Rick Curtis [curti...@gmail.com] Sent: Thursday, June 13, 2013 5:12 PM To: users Subject: [External] Re: OpenJPA Null Update Are you getting an error or something... or is it just being ignored? If it is being ignored, can you better describe the scenario that you're running? On Thu, Jun 13, 2013 at 3:00 PM, Tibebu, Nebiyou [USA] tibebu_nebi...@bah.commailto:tibebu_nebi...@bah.com wrote: I am unable to update Nullable VARCHAR columns in Mainframe DB2 to NULL. Update to other values, including an empty string works fine. I would appreciate some assistance. This is in version 2.2.1. Nebiyou Tibebu Senior Consultant 13200 Woodland Park Rd, Herndon, VA 21071 Email: tibebu_nebi...@bah.commailto:tibebu_nebi...@bah.com Tel: (703) 377-5425tel:%28703%29%20377-5425 Cell: (571) 422-5178tel:%28571%29%20422-5178 [http://www.soaschool.com/system/application/images/soacp_architect.jp g] Booz Allen Hamilton | http://www.boozallen.comhttp://www.boozallen.com/ -- Rick Curtis
getDataStoreAction comes as empty String[] when caching is enabled
I'm not sure if this is a bug or if my understanding of the way how it should work is wrong. Maybe someone can help me out a little bit. In an application (WebSphere 8.0.0.5, OpenJPA 2.1.2) I need to get the generated native SQL String from an JPQL to manipulate it. It is working great but when I activate the QueryCache (2nd level) the result is coming as an empty string-array. I investigated a little bit in debugging and have found this code in the kernel package: QueryCacheExecuter#QueryCacheStoreQuery.getDataStoreActions(...): The implementation of this method is quite simple: return EMPTY_STRINGS; :) Maybe my way of thinking is wrong, but shouldn't there be the implementation for returning the native query string? When I deactivate the Cache the implementation of ExpressionStoreQuery is executed which is working fine. Regards jens
Re: [External] Re: OpenJPA Null Update
You could set the property openjpa.DetachState(DetachedStateField=true). This property will make our DetachedStateManager serializeable and then the JPA runtime can 'track' a detached Entity. The only down side to this approach is that the OpenJPA classes must be on the classpath of the client that your Entities are being streamed to. I'll also note that this property is important to be set prior to enhancement because it changes our enhanced bytecode. Let me know how it goes. Thanks, Rick [1] http://ci.apache.org/projects/openjpa/trunk/docbook/manual.html#ref_guide_detach_graph On Fri, Jun 14, 2013 at 1:37 AM, Boblitz John john.bobl...@bertschi.comwrote: Hello, I think that Chapter 12.1.2 in the Manual will help here. When attaching null fields in these cases, OpenJPA cannot distinguish between a field that was unloaded and one that was intentionally set to null. In this case, OpenJPA will use the current detach state setting to determine how to handle null fields: fields that would have been included in the detached state are treated as loaded, and will in turn set the corresponding attached field to null. Regards, John -Original Message- From: Tibebu, Nebiyou [USA] [mailto:tibebu_nebi...@bah.com] Sent: Friday, June 14, 2013 5:26 AM To: users@openjpa.apache.org Subject: RE: [External] Re: OpenJPA Null Update Rick, Thank you for your help. Here is the scenario: 1. Get a persistent instance of an entity 2. Detach entity 3. Update values on the entity with non-null values 4. One of these values will be a string value with existing non-trivial data 5. Set the value on this field to null 6. Merge entity 7. All other fields are updated except this value. Nebiyou Tibebu Booz | Allen | Hamilton 8283 Greensboro Dr, Mclean, VA 22102 tibebu_nebi...@bah.com From: Rick Curtis [curti...@gmail.com] Sent: Thursday, June 13, 2013 10:31 PM To: users@openjpa.apache.org Subject: RE: [External] Re: OpenJPA Null Update Well, you are going to have to describe what your scenario is for any of us to help you out. On Jun 13, 2013 6:57 PM, Tibebu, Nebiyou [USA] tibebu_nebi...@bah.com wrote: I am not getting any errors. It is just being ignored. Nebiyou Tibebu Booz | Allen | Hamilton 8283 Greensboro Dr, Mclean, VA 22102 tibebu_nebi...@bah.com From: Tibebu, Nebiyou [USA] Sent: Thursday, June 13, 2013 5:55 PM To: users@openjpa.apache.org Subject: RE: [External] Re: OpenJPA Null Update Nebiyou Tibebu Booz | Allen | Hamilton 8283 Greensboro Dr, Mclean, VA 22102 tibebu_nebi...@bah.com From: Rick Curtis [curti...@gmail.com] Sent: Thursday, June 13, 2013 5:12 PM To: users Subject: [External] Re: OpenJPA Null Update Are you getting an error or something... or is it just being ignored? If it is being ignored, can you better describe the scenario that you're running? On Thu, Jun 13, 2013 at 3:00 PM, Tibebu, Nebiyou [USA] tibebu_nebi...@bah.commailto:tibebu_nebi...@bah.com wrote: I am unable to update Nullable VARCHAR columns in Mainframe DB2 to NULL. Update to other values, including an empty string works fine. I would appreciate some assistance. This is in version 2.2.1. Nebiyou Tibebu Senior Consultant 13200 Woodland Park Rd, Herndon, VA 21071 Email: tibebu_nebi...@bah.commailto:tibebu_nebi...@bah.com Tel: (703) 377-5425tel:%28703%29%20377-5425 Cell: (571) 422-5178tel:%28571%29%20422-5178 [http://www.soaschool.com/system/application/images/soacp_architect.jp g] Booz Allen Hamilton | http://www.boozallen.comhttp://www.boozallen.com/ -- Rick Curtis -- *Rick Curtis*
Re: ClassCastException - org.apache.openjpa.util.IntId incompatible
Thanks Kevin, I tried setting the QuerySQLCache to false but that didn't seem to fix the issue. I am still seeing those exceptions. Does it have to do anything with class loaders or maybe something with the way I currently have setup my parent-child relations As mentioned before it works fine if there is just one record in my parent table, if more than one then I get the exception. Here are my parent child class //Parent super class @MappedSuperclass @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) @Access(AccessType.FIELD) public abstract class TransactionQueue { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name=TransactionID) private int transactionId; .. other field omitted } //Parent class @Entity @Access(AccessType.FIELD) public class OrderTransactionQueue extends TransactionQueue implements Serializable { private static final long serialVersionUID = 1L; @OneToMany(mappedBy=orderTransactionQueue, fetch=FetchType.EAGER, cascade=CascadeType.ALL,targetEntity=OrderTransaction.class) private ListOrderTransaction orderTransactions; } //Child class @Entity @IdClass(OrderTransactionPK.class) public class OrderTransaction implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(name=OrderNum) private int orderNum; //bi-directional many-to-one association to OrderTransactionQueue @ManyToOne @JoinColumn(name=TransactionID) @Id private OrderTransactionQueue orderTransactionQueue; } //Child Id class public class OrderTransactionPK implements Serializable { //default serial version id, required for serializable classes. private static final long serialVersionUID = 1L; private int orderNum; private int orderTransactionQueue; } Please, let me know if you need more information. Thanks, Javid On Thu, Jun 13, 2013 at 2:36 PM, Kevin Sutter [via OpenJPA] ml-node+s208410n7584159...@n2.nabble.com wrote: Since you are using WebSphere, I would also suggest opening a PMR for this problem through the normal IBM support channels. If this question does turn into something real and requires an iFix, then you'll need the PMR and APAR to get the fix delivered anyway... Since your query works some of the times and not others, my first guess is that there might be an issue with the SQL cache. You can quickly verify this by turning off the SQL cache via this property. If that works for you, at least you have a workaround until a real fix can be determined. property name=openjpa.jdbc.QuerySQLCache value=false There are other options with this Cache that might help you out. For example, if turning off the Cache completely gets you around the problem, then you could just turn it off for a specific query. Details can be found in the documentation [1]. Hope this helps get you started. Kevin [1] http://ci.apache.org/projects/openjpa/trunk/docbook/manual.html#ref_guide_cache_querysql On Thu, Jun 13, 2013 at 1:12 PM, javid.alimohideen [hidden email] http://user/SendEmail.jtp?type=nodenode=7584159i=0 wrote: Hi, I have web application running on Websphere v8.5, that uses a JPA project configured as utility project. The application suddenly started throwing ClassCastException when performing select query. I have pasted the exception stack trace. The weird things is it works sometime and at times I get this exception. Also, if the DB tables have just one record then everything works fine, if there are more than 1 record then I see this exception The entities have a OneToMany and ManyToOne relationships defined. Caused by: java.lang.ClassCastException: org.apache.openjpa.util.IntId incompatible with com.jpa.dom.transactionqueue.BlockTransactionQueue at com.jpa.dom.transactionqueue.BlockCompleteTransaction.pcReplaceField(BlockCompleteTransaction.java) at org.apache.openjpa.kernel.StateManagerImpl.replaceField(StateManagerImpl.java:3174) at org.apache.openjpa.kernel.StateManagerImpl.storeObjectField(StateManagerImpl.java:2602) at org.apache.openjpa.kernel.StateManagerImpl.storeObject(StateManagerImpl.java:2592) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.setMappedBy(JDBCStoreManager.java:476) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:402) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:304) at com.ibm.ws.persistence.jdbc.kernel.WsJpaJDBCStoreManager.initialize(WsJpaJDBCStoreManager.java:149) at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112) at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57) at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1036) at
Re: OpenJPA support for JPA 2.1: when?
Hi Matthew, I greatly appreciate your insights. And, I'm 100% behind you on this. OpenJPA has a great, large set of users. We get feedback from all facets of the industry and we try to respond to the best of our ability. Like the squeaky wheel, we pay the most attention to those areas requesting attention. As you've seen, I have tried to generate and gauge interest in JPA 2.1. Mark has expressed some interest and, of course, Pinaki has. And, now your note is the strongest worded request for JPA 2.1. So, it's great to hear that there's finally some interest. This is totally different from the JPA 2.0 effort. When that one was discussed on the OpenJPA forums, there was much more interest from a development perspective with several individuals and teams stepping up -- coding, testing, id, promotion, etc. For whatever reason, the interest in JPA 2.1 is not as strong. Since most of us have day jobs in addition to contributing to open-source, we have to pick what areas to focus on. If there is interest in kicking off a real development effort, then we should probably move this conversation to the dev mailing list and get the development community fired up. Anybody else have input? Kevin On Thu, Jun 13, 2013 at 9:52 PM, Matthew Adams matt...@matthewadams.mewrote: responses inline... On Thu, Jun 13, 2013 at 2:27 PM, Kevin Sutter kwsut...@gmail.com wrote: Good question, Matthew. This has been brought up a couple of different times... http://openjpa.208410.n2.nabble.com/JPA-2-1-td7215602.html http://openjpa.208410.n2.nabble.com/DISCUSSION-JPA-2-1-spec-implementation-td7581978.html So, there's been some interest, but not an overwhelming interest. Not to the point of creating a team, figuring out the work effort, and divvying up the responsibilities. Contrast that with the JPA 2.0 development effort, and there was overwhelming community support and participation. So, I think there are a handful of us interested in a JPA 2.1 implementation, but more participation is required. Pardon my surprise, but that sounds just plain bad. That kind of sentiment threatens to scare users away, IMHO. I have always held OpenJPA in high esteem as one of the major, credible implementations because it's always been up to date WRT to the specs (and, let's not kid ourselves, it hails from Kodo JDO). Frankly, the specs don't move very fast, and at least previews of them are available well in advance of the actual GA releases. Pinaki has went so far to create a sandbox and start experimenting with an implementation. Again, he's a one-man show and can't do it all. Well, he probably could, but it would require a bit of work... :-) https://svn.apache.org/repos/asf/openjpa/sandboxes/21 Well, I would have expected a team of folks on this, not just one. After all, Pinaki was arguing for expanded fetch plan capabilities in the JPA expert group based on OpenJPA's current capabilities -- and rightfully so, I might add. Maybe we should resurrect that [DISCUSSION] topic I think you should. Especially with any support customers you or the OpenJPA project sponsors may have. but I'm curious what features of JPA 2.1 are of most interest to you? Or, is it just a matter of being consistent with the latest specification? One feature that's worth its development weight is fetch plans, which OpenJPA, thanks to its current fetch plan implementation, can implement fairly quickly. Further, OpenJPA's fetch plan support exceeds JPA's requirement with fetch depth and recursion depth! Additionally, I just happen to be writing an advanced JPA course right now, and customers of this course want to use the JPA implementation in the course that they have settled on in their organization. It just so happens that the maiden voyage of this course covers JPA 2.1 and is for a customer that is also an OpenJPA customer. And they're large. Now, I have to tell them Sorry, OpenJPA doesn't have plans to implement JPA 2.1. Can you say, Bye bye, customer? EclipseLink DataNucleus already implement 2.1, and Hibernate's implementation is in progress. If not for the technical reasons I gave above, then the need to remain competitive should be enough to have you assemble a crack 2.1 team ASAP. Don't forget about BatooJPA making noise (claiming top performance, although I take that with a few grains of salt) and the NoSQL JPA implementations (DataNucleus, ObjectDB, and Kundera), not to mention the Spring Data projects. Like it or not, you are beset on all sides with competition. Just my $0.02, which might just be worth around $0.029 with the interest I've accumulated since working with JDO- JPA-style lightweight persistence since 1996 and with the expert groups since 2000. Thanks, Kevin On Thu, Jun 13, 2013 at 2:03 PM, Matthew Adams matt...@matthewadams.me wrote: When will OpenJPA support JPA 2.1? -matthew --
Re: OpenJPA support for JPA 2.1: when?
Hi Kevin I think that OpenJPA is great and the way it stuck to JPA 2.0 Standard so quick was very good. As I am looking more and more into the JEE and the desktop side of things is just as important to me, world it would be great to keep the provider I know so well. I am may even be able to help in the future as well as I once did before for some documentation and bugs. I am definitely interested in helping if I can keep OpenJPA up to date. Thanks David On 14/06/13 17:27, Kevin Sutter wrote: Hi Matthew, I greatly appreciate your insights. And, I'm 100% behind you on this. OpenJPA has a great, large set of users. We get feedback from all facets of the industry and we try to respond to the best of our ability. Like the squeaky wheel, we pay the most attention to those areas requesting attention. As you've seen, I have tried to generate and gauge interest in JPA 2.1. Mark has expressed some interest and, of course, Pinaki has. And, now your note is the strongest worded request for JPA 2.1. So, it's great to hear that there's finally some interest. This is totally different from the JPA 2.0 effort. When that one was discussed on the OpenJPA forums, there was much more interest from a development perspective with several individuals and teams stepping up -- coding, testing, id, promotion, etc. For whatever reason, the interest in JPA 2.1 is not as strong. Since most of us have day jobs in addition to contributing to open-source, we have to pick what areas to focus on. If there is interest in kicking off a real development effort, then we should probably move this conversation to the dev mailing list and get the development community fired up. Anybody else have input? Kevin On Thu, Jun 13, 2013 at 9:52 PM, Matthew Adams matt...@matthewadams.mewrote: responses inline... On Thu, Jun 13, 2013 at 2:27 PM, Kevin Sutter kwsut...@gmail.com wrote: Good question, Matthew. This has been brought up a couple of different times... http://openjpa.208410.n2.nabble.com/JPA-2-1-td7215602.html http://openjpa.208410.n2.nabble.com/DISCUSSION-JPA-2-1-spec-implementation-td7581978.html So, there's been some interest, but not an overwhelming interest. Not to the point of creating a team, figuring out the work effort, and divvying up the responsibilities. Contrast that with the JPA 2.0 development effort, and there was overwhelming community support and participation. So, I think there are a handful of us interested in a JPA 2.1 implementation, but more participation is required. Pardon my surprise, but that sounds just plain bad. That kind of sentiment threatens to scare users away, IMHO. I have always held OpenJPA in high esteem as one of the major, credible implementations because it's always been up to date WRT to the specs (and, let's not kid ourselves, it hails from Kodo JDO). Frankly, the specs don't move very fast, and at least previews of them are available well in advance of the actual GA releases. Pinaki has went so far to create a sandbox and start experimenting with an implementation. Again, he's a one-man show and can't do it all. Well, he probably could, but it would require a bit of work... :-) https://svn.apache.org/repos/asf/openjpa/sandboxes/21 Well, I would have expected a team of folks on this, not just one. After all, Pinaki was arguing for expanded fetch plan capabilities in the JPA expert group based on OpenJPA's current capabilities -- and rightfully so, I might add. Maybe we should resurrect that [DISCUSSION] topic I think you should. Especially with any support customers you or the OpenJPA project sponsors may have. but I'm curious what features of JPA 2.1 are of most interest to you? Or, is it just a matter of being consistent with the latest specification? One feature that's worth its development weight is fetch plans, which OpenJPA, thanks to its current fetch plan implementation, can implement fairly quickly. Further, OpenJPA's fetch plan support exceeds JPA's requirement with fetch depth and recursion depth! Additionally, I just happen to be writing an advanced JPA course right now, and customers of this course want to use the JPA implementation in the course that they have settled on in their organization. It just so happens that the maiden voyage of this course covers JPA 2.1 and is for a customer that is also an OpenJPA customer. And they're large. Now, I have to tell them Sorry, OpenJPA doesn't have plans to implement JPA 2.1. Can you say, Bye bye, customer? EclipseLink DataNucleus already implement 2.1, and Hibernate's implementation is in progress. If not for the technical reasons I gave above, then the need to remain competitive should be enough to have you assemble a crack 2.1 team ASAP. Don't forget about BatooJPA making noise (claiming top performance, although I take that with a few grains of salt) and the NoSQL JPA implementations (DataNucleus, ObjectDB, and Kundera), not to mention the Spring Data projects.
Re: Help needed with Fields 'xxx' are not a default persistent type warning
Found an answer to my question, apparently a minor bug in OpenJPA ( https://issues.apache.org/jira/browse/OPENJPA-2401), in which XML configuration is not being consulted when deciding to print that warning message. Glen On 06/13/2013 10:01 PM, Glen Mazza wrote: Hi, I'm new to OpenJPA (and JPA) and trying to create the entity-mapping XML files (classes are unannotated POJOs) for a simple parent-child database relationship[1] (parent is department, child is employees working at that department) Right now, here's what I have for the mapping files:[2] (classes are here: [3]). While my TestClass[4] (which accesses just the department table right now) runs fine I'm getting this warning message while running it: 2213 CompanyPU WARN [main] openjpa.Runtime - Fields employees are not a default persistent type, and do not have any annotations indicating their persistence strategy. They will be treated as non-persistent. If you intended for these fields to be persistent, be sure to annotate them appropriately. Otherwise annotate them with @Transient. Google is returning many examples of others with this error, but I'm still not sure what I'm doing wrong. In the department.orm.xml, I can't map employees as Transient because it is already mapped as one-to-many/, which is AFAICT the right mapping to do. Basically, what do I have to fix my department.orm.xml[2] (or Department.java class[3]) in order to get rid of the above warning message? Thanks, Glen [1] https://github.com/gmazza/blog-samples/blob/master/jpa_and_junit/src/main/config/create-database-derby.sql [2] https://github.com/gmazza/blog-samples/tree/master/jpa_and_junit/src/main/resources/entities [3] https://github.com/gmazza/blog-samples/tree/master/jpa_and_junit/src/main/java/entities [4] https://github.com/gmazza/blog-samples/blob/master/jpa_and_junit/src/main/java/TestClass.java