Re: How to release db connection into pool?

2010-01-21 Thread wang yu
Craig,
 I have tested it. It's cool!
The db connection will be returned into pool and I can reuse the
JPAEntityManager!
Thanks again.

Regards,
Yu Wang

On Fri, Jan 22, 2010 at 9:57 AM, wang yu wangy...@gmail.com wrote:
 Craig:
 Thank you for your quick response.
 If I close it, the connection will be returned into pool or just destroyed?

 Regards,
 Yu Wang

 On Thu, Jan 21, 2010 at 8:56 PM, Craig L Russell craig.russ...@sun.com 
 wrote:
 Hi Yu Wang,

 You need to tell OpenJPA that you're not using the Connection any more by
 calling close(). See this Example 4.4 in the user's manual:

 import java.sql.*;
  import org.apache.openjpa.persistence.*;
  ... OpenJPAEntityManager kem = OpenJPAPersistence.cast(em);
 Connection conn = (Connection) kem.getConnection();
  // do JDBC stuff
  conn.close();

 Regards,

 Craig
 On Jan 21, 2010, at 1:26 AM, wang yu wrote:

 Gurus:
 I use OpenJPA 1.2.1 and dbcp:
                        property name=openjpa.ConnectionDriverName

  value=org.apache.commons.dbcp.BasicDataSource /
                        property name=openjpa.ConnectionProperties

  value=driverClassName=oracle.jdbc.driver.OracleDriver,
 url=jdbc:oracle:thin:@localhost:1521:orcl, username=,
 password=XXX, maxActive=8, maxWait=1, poolPreparedStatements=true
 /

 And I found the connection pool worked perfect for JPA query. But if I
 use JDBC query like following:
                OpenJPAEntityManager open_manager = OpenJPAPersistence
                                        .cast(entitiManager);
                Connection conn = (Connection)
 open_manager.getConnection();
                java.sql.PreparedStatement PrepStmt = null;
                java.sql.ResultSet sqlResults = null;
                try {
                        PrepStmt = connection
                                        .prepareStatement(select * from
 tsam.MON_BRIDGE);
                        sqlResults = PrepStmt.executeQuery();
                } catch (SQLException e) {
                        log.error(e.getMessage());
                } finally {
                        try {
                                if (sqlResults != null)
                                        sqlResults.close();
                                if (PrepStmt != null)
                                        PrepStmt.close();
                        } catch (SQLException e) {

                        }
                }

 The connection cannot be put into pool and the result is out of db
 connection.
 How should I do?  Should I use createNativeQuery(String sql, Class
 resultClass)  to query with native sql?


 Regards,
 Yu Wang

 Craig L Russell
 Architect, Sun Java Enterprise System http://db.apache.org/jdo
 408 276-5638 mailto:craig.russ...@sun.com
 P.S. A good JDO? O, Gasp!





Re: How to encrypt DB password in persistence.xml

2009-09-01 Thread wang yu
Hello, Mike,
Do we have a target day for OpenJPA 2.0 GA?
From http://openjpa.apache.org/jpa-20-roadmap.html , may I assume it
will be released before the end of the year?

Both password Encryption and get cache from factory in JPA spec  are
very useful for me.
I use Spring to manager the life circle of manager factory, it's
difficult to cast factory into OpenJPAEntityManagerFactory directly.

Regards,
Yu Wang


On Fri, Aug 14, 2009 at 11:27 AM, Michael Dickmichael.d.d...@gmail.com wrote:
 Hi,
 OpenJPA doesn't know (or care) how much of the password is encrypted - that
 determination is up to the encryption provider (ie your code). So if the
 encryption provider can figure out which parts of the string need to be
 decrypted and which parts do not then you should be set.

 I just reopened the issue to port it to version 1.3.0 so this feature will
 be available in the next major (2.0.0) and minor (1.3.0) versions of
 OpenJPA.

 In the mean time you can grab a nightly build from the builds
 pagehttp://openjpa.apache.org/downloads.html (look
 for 2.0.0-SNAPSHOT). I'll  try to get the fix ported to 1.3.0 this weekend
 too.

 -mike



 On Thu, Aug 13, 2009 at 8:58 PM, wang yu wangy...@gmail.com wrote:

 Mike,
 Thanks a lot!
 Since I used DBCP datasource as following:
        property name=openjpa.ConnectionProperties

  value=driverClassName=oracle.jdbc.driver.OracleDriver,
 url=jdbc:oracle:thin:@localhost:1521:orcl, username=XXX, password=XXX,
 maxActive=8, maxWait=1, poolPreparedStatements=true /


 May I  encrypt a sub string of property value rather than full
 property value string?

 Anyway, when will this feature be available? In a new release or a
 rolling patch?

 Regards,
 Yu Wang


 On Fri, Aug 7, 2009 at 9:33 PM, Michael Dickmichael.d.d...@gmail.com
 wrote:
  Hi Yu,
 
  At the moment our support allows you to specify an 'Encryption Provider'
  which handles the encryption / decryption of a password. We aren't
 providing
  a tool to do the actual encryption - just a plugin point for other tools.
 
  It sounds like you have written the encryption code in your extension for
  DBCP so it should be fairly easy to wrap in an encryption provider.
 
  Hope this helps,
  -mike
 
  On Fri, Aug 7, 2009 at 1:25 AM, wang yu wangy...@gmail.com wrote:
 
  Rick,
  Thank you for your information. I have resolved this issue by
  modifying dbcp source code.
  The bad part is dbcp can be built with jdk 1.4 only which made build
  system little bit complicated:-)
 
  If you can deliver encryption feature in next release, I'll be very
  pleased to use it.
 
  Regards,
  Yu Wang
 
 
  On Fri, Aug 7, 2009 at 5:22 AM, Rick Curtiscurti...@gmail.com wrote:
  
   Yu Wang -
  
   OPENJPA-1089[1] wasn't your exact problem, but I want you to be aware
  that a
   change was made.
  
   Thanks -
   Rick
  
   [1] https://issues.apache.org/jira/browse/OPENJPA-1089
   --
   View this message in context:
 
 http://n2.nabble.com/How-to-encrypt-DB-password-in-persistence.xml-tp2868212p3400811.html
   Sent from the OpenJPA Users mailing list archive at Nabble.com.
  
 
 




Re: How to encrypt DB password in persistence.xml

2009-08-13 Thread wang yu
Mike,
Thanks a lot!
Since I used DBCP datasource as following:
property name=openjpa.ConnectionProperties

value=driverClassName=oracle.jdbc.driver.OracleDriver,
url=jdbc:oracle:thin:@localhost:1521:orcl, username=XXX, password=XXX,
maxActive=8, maxWait=1, poolPreparedStatements=true /


May I  encrypt a sub string of property value rather than full
property value string?

Anyway, when will this feature be available? In a new release or a
rolling patch?

Regards,
Yu Wang


On Fri, Aug 7, 2009 at 9:33 PM, Michael Dickmichael.d.d...@gmail.com wrote:
 Hi Yu,

 At the moment our support allows you to specify an 'Encryption Provider'
 which handles the encryption / decryption of a password. We aren't providing
 a tool to do the actual encryption - just a plugin point for other tools.

 It sounds like you have written the encryption code in your extension for
 DBCP so it should be fairly easy to wrap in an encryption provider.

 Hope this helps,
 -mike

 On Fri, Aug 7, 2009 at 1:25 AM, wang yu wangy...@gmail.com wrote:

 Rick,
 Thank you for your information. I have resolved this issue by
 modifying dbcp source code.
 The bad part is dbcp can be built with jdk 1.4 only which made build
 system little bit complicated:-)

 If you can deliver encryption feature in next release, I'll be very
 pleased to use it.

 Regards,
 Yu Wang


 On Fri, Aug 7, 2009 at 5:22 AM, Rick Curtiscurti...@gmail.com wrote:
 
  Yu Wang -
 
  OPENJPA-1089[1] wasn't your exact problem, but I want you to be aware
 that a
  change was made.
 
  Thanks -
  Rick
 
  [1] https://issues.apache.org/jira/browse/OPENJPA-1089
  --
  View this message in context:
 http://n2.nabble.com/How-to-encrypt-DB-password-in-persistence.xml-tp2868212p3400811.html
  Sent from the OpenJPA Users mailing list archive at Nabble.com.
 




Re: How to encrypt DB password in persistence.xml

2009-08-07 Thread wang yu
Rick,
Thank you for your information. I have resolved this issue by
modifying dbcp source code.
The bad part is dbcp can be built with jdk 1.4 only which made build
system little bit complicated:-)

If you can deliver encryption feature in next release, I'll be very
pleased to use it.

Regards,
Yu Wang


On Fri, Aug 7, 2009 at 5:22 AM, Rick Curtiscurti...@gmail.com wrote:

 Yu Wang -

 OPENJPA-1089[1] wasn't your exact problem, but I want you to be aware that a
 change was made.

 Thanks -
 Rick

 [1] https://issues.apache.org/jira/browse/OPENJPA-1089
 --
 View this message in context: 
 http://n2.nabble.com/How-to-encrypt-DB-password-in-persistence.xml-tp2868212p3400811.html
 Sent from the OpenJPA Users mailing list archive at Nabble.com.



Re: Timestamp in JPQL where clause issue

2009-07-28 Thread wang yu
Pinaki,
Yes ,you're right.
Thanks!

Yu Wang

On Mon, Jul 27, 2009 at 8:32 PM, Pinaki Poddarppod...@apache.org wrote:

 Hi,
  Can you please change the parameter name from to something else?
 The error is during parse and may have be related to the fact that from is
 a reserved word in JPQL.



 -
 Pinaki
 --
 View this message in context: 
 http://n2.nabble.com/Timestamp-in-JPQL-where-clause-issue-tp3332190p550.html
 Sent from the OpenJPA Users mailing list archive at Nabble.com.



Timestamp in JPQL where clause issue

2009-07-27 Thread wang yu
Hello,
I met an OpenJPA Timestamp filed in JPQL where clause issue.
I used it as:
EntityManagerFactory factory = 
Persistence.createEntityManagerFactory(
test, System.getProperties());
String sql= SELECT callpath FROM Callpath callpath WHERE
callpath.starttime  :from;
Query query = factory.createEntityManager().createQuery(sql);
query.setParameter(from, new
Timestamp(System.currentTimeMillis()), TemporalType.TIMESTAMP);
query.getResultList();

The Exception stack:
openjpa-1.2.1-r752877:753278 nonfatal user error
org.apache.openjpa.persistence.ArgumentException: Encountered
callpath . starttime  : from at character 46, but expected: [(,
*, +, -, ., /, :, , =, , =, , =, ?,
ABS, ALL, AND, ANY, AS, ASC, AVG, BETWEEN, BOTH,
BY, CONCAT, COUNT, CURRENT_DATE, CURRENT_TIME,
CURRENT_TIMESTAMP, DELETE, DESC, DISTINCT, EMPTY, ESCAPE,
EXISTS, FETCH, FROM, GROUP, HAVING, IN, INNER, IS,
JOIN, LEADING, LEFT, LENGTH, LIKE, LOCATE, LOWER, MAX,
MEMBER, MIN, MOD, NEW, NOT, NULL, OBJECT, OF, OR,
ORDER, OUTER, SELECT, SET, SIZE, SOME, SQRT,
SUBSTRING, SUM, TRAILING, TRIM, UPDATE, UPPER, WHERE,
DECIMAL_LITERAL, IDENTIFIER, INTEGER_LITERAL, STRING_LITERAL].
at 
org.apache.openjpa.kernel.jpql.JPQL.generateParseException(JPQL.java:9501)
at org.apache.openjpa.kernel.jpql.JPQL.jj_consume_token(JPQL.java:9378)
at 
org.apache.openjpa.kernel.jpql.JPQL.conditional_primary(JPQL.java:1947)
at 
org.apache.openjpa.kernel.jpql.JPQL.conditional_factor(JPQL.java:1925)
at org.apache.openjpa.kernel.jpql.JPQL.conditional_term(JPQL.java:1791)
at 
org.apache.openjpa.kernel.jpql.JPQL.conditional_expression(JPQL.java:1753)
at org.apache.openjpa.kernel.jpql.JPQL.where_clause(JPQL.java:1556)
at org.apache.openjpa.kernel.jpql.JPQL.select_statement(JPQL.java:91)
at org.apache.openjpa.kernel.jpql.JPQL.parseQuery(JPQL.java:63)
at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1740)
at 
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.init(JPQLExpressionBuilder.java:1727)
at org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:48)
at 
org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:149)
at 
org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:657)
at 
org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:625)
at 
org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605)
at 
org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667)
at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1492)
at 
org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:243)
at 
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)

And I noticed a bug track:
http://mail-archives.apache.org/mod_mbox/openjpa-dev/200801.mbox/%3c2013506.1200781234450.javamail.j...@brutus%3e

Has it been resolved? Or do I have a workaround?

Thanks!

Regards,
Yu Wang


Re: Timestamp in JPQL where clause issue

2009-07-27 Thread wang yu
And I used OpenJPA 1.2.1.

-Yu Wang

On Mon, Jul 27, 2009 at 2:20 PM, wang yuwangy...@gmail.com wrote:
 Hello,
 I met an OpenJPA Timestamp filed in JPQL where clause issue.
 I used it as:
                EntityManagerFactory factory = 
 Persistence.createEntityManagerFactory(
                                test, System.getProperties());
                String sql= SELECT callpath FROM Callpath callpath WHERE
 callpath.starttime  :from;
                Query query = factory.createEntityManager().createQuery(sql);
                query.setParameter(from, new
 Timestamp(System.currentTimeMillis()), TemporalType.TIMESTAMP);
                query.getResultList();

 The Exception stack:
 openjpa-1.2.1-r752877:753278 nonfatal user error
 org.apache.openjpa.persistence.ArgumentException: Encountered
 callpath . starttime  : from at character 46, but expected: [(,
 *, +, -, ., /, :, , =, , =, , =, ?,
 ABS, ALL, AND, ANY, AS, ASC, AVG, BETWEEN, BOTH,
 BY, CONCAT, COUNT, CURRENT_DATE, CURRENT_TIME,
 CURRENT_TIMESTAMP, DELETE, DESC, DISTINCT, EMPTY, ESCAPE,
 EXISTS, FETCH, FROM, GROUP, HAVING, IN, INNER, IS,
 JOIN, LEADING, LEFT, LENGTH, LIKE, LOCATE, LOWER, MAX,
 MEMBER, MIN, MOD, NEW, NOT, NULL, OBJECT, OF, OR,
 ORDER, OUTER, SELECT, SET, SIZE, SOME, SQRT,
 SUBSTRING, SUM, TRAILING, TRIM, UPDATE, UPPER, WHERE,
 DECIMAL_LITERAL, IDENTIFIER, INTEGER_LITERAL, STRING_LITERAL].
        at 
 org.apache.openjpa.kernel.jpql.JPQL.generateParseException(JPQL.java:9501)
        at org.apache.openjpa.kernel.jpql.JPQL.jj_consume_token(JPQL.java:9378)
        at 
 org.apache.openjpa.kernel.jpql.JPQL.conditional_primary(JPQL.java:1947)
        at 
 org.apache.openjpa.kernel.jpql.JPQL.conditional_factor(JPQL.java:1925)
        at org.apache.openjpa.kernel.jpql.JPQL.conditional_term(JPQL.java:1791)
        at 
 org.apache.openjpa.kernel.jpql.JPQL.conditional_expression(JPQL.java:1753)
        at org.apache.openjpa.kernel.jpql.JPQL.where_clause(JPQL.java:1556)
        at org.apache.openjpa.kernel.jpql.JPQL.select_statement(JPQL.java:91)
        at org.apache.openjpa.kernel.jpql.JPQL.parseQuery(JPQL.java:63)
        at 
 org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1740)
        at 
 org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.init(JPQLExpressionBuilder.java:1727)
        at org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:48)
        at 
 org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:149)
        at 
 org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:657)
        at 
 org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:625)
        at 
 org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605)
        at 
 org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667)
        at 
 org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1492)
        at 
 org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123)
        at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:243)
        at 
 org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)

 And I noticed a bug track:
 http://mail-archives.apache.org/mod_mbox/openjpa-dev/200801.mbox/%3c2013506.1200781234450.javamail.j...@brutus%3e

 Has it been resolved? Or do I have a workaround?

 Thanks!

 Regards,
 Yu Wang



Re: Exception of merge method.

2009-07-14 Thread wang yu
Hi mike,
Yes, id field with @GeneratedValue(strategy=GenerationType.AUTO)
annotation  is the primary key field and I didn't serialize the
entity.
I just modified some fields of the entity in the same VM and try to
merge the entity into a new context.

Regards,
Yu Wang

On Tue, Jul 14, 2009 at 9:38 PM, Michael Dickmichael.d.d...@gmail.com wrote:
 Hi Yu,

 This is not expected behavior. You should be able to detach and merge your
 entity into a new persistence context.

 The error you're getting is because you have a value specified in a
 GeneratedField (ie in your entity you have @GeneratedValue on the field).
 The field in question is Policy.id (sounds like your Primary Key).. Have you
 modified this field after closign the original context?

 If not then it's probably a case of OpenJPA not realizing that the field was
 loaded (ie not set after detaching). Did you serialize the entity after
 closing the original context (if so there are other properties that you may
 need to set).

 -mike

 On Tue, Jul 14, 2009 at 3:21 AM, wang yu wangy...@gmail.com wrote:

 Hello,
 I uses OpenJPA 1.2.1.
 Even if I add @Version annotation for the entity class,It doesn't work.
 Every time the merge method is used, OpenJPA try to insert a new row
 into database.

 So, is it a expected behavior of OpenJPA? Merge method cannot attach a
 detached entity into a new context?

 Regards,
 Yu Wang

 On Mon, Jul 13, 2009 at 5:44 PM, wang yuwangy...@gmail.com wrote:
  Hello,
  My case is:
  1. Find an entity and close the context.
  2. Update it with user input.
  3. Create a new EntityManager and try to merge it into new context.
 
  Then the following exception was thrown:
 
  openjpa-1.2.1-r752877:753278 nonfatal user error
  org.apache.openjpa.persistence.InvalidStateException: The generated
  value processing detected an existing value assigned to this field:
  com.XXX.bean.Policy.id.  This existing value was either provided via
  an initializer or by calling the setter method.  You either need to
  remove the @GeneratedValue annotation or modify the code to remove the
  initializer processing.
 
  org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:483)
 
  org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:463)
 
  org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignObjectId(JDBCStoreManager.java:744)
 
  org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(DelegatingStoreManager.java:134)
 
  org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(DelegatingStoreManager.java:134)
 
  org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:520)
 
  org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2824)
         org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:39)
 
  org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:960)
         org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1948)
 
  org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
 
  org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1826)
 
  org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
         org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1350)
 
  org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:877)
 
  org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:512)
         com.XXX.dao.DAOContainer.commitTransaction(DAOContainer.java:195)
 
  com.XXX.policy.PolicyServiceImpl.update(PolicyServiceImpl.java:272)
         com.XXX.ds.ServletIndex.doGet(ServletIndex.java:78)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 
  What's the root cause of this exception?
  Thanks!
 
  Regards,
  Yu Wang
 




Foreign key error if using GenerationType.AUTO or GenerationType.TABLE

2009-06-22 Thread wang yu
Hello,
If I use GenerationType.AUTO or GenerationType.TABLE for PK field and
let OpenJPA persist some entities cascade , in some cases, OpenJPA
will try to persist child entity before the father entity.
How to resolve this issue?

I must use GenerationType.AUTO for oracle because it doesn't support
GenerationType.IDENTITY naturally.
Or do I have a chance to use  GenerationType.IDENTITY  for Pk fields
of oracle database?

I have attached the log information in attached file.

Thanks!

Regards,
Yu Wang


Re: Foreign key error if using GenerationType.AUTO or GenerationType.TABLE

2009-06-22 Thread wang yu
hello mike,
Thank you for your prompt and detailed response.

I use OpenJPA 1.2.1.

I have added foolowing into persistence.xml
property name=openjpa.jdbc.SynchronizeMappings
value=buildSchema(ForeignKeys=true) /
property name=openjpa.jdbc.UpdateManager 
value=operation-order/

and @ForeignKey(enabled=true) for all foreign key fields according to
your suggestion.

For GenerationType.AUTO, some insert operation still failed.

My case is little bit complicated, it has very deep entity hierarchy
and mixed with insert,update and delete operations in one deep entity
tree.

I'm afraid the root cause is UpdateManager of OpenJPA is not so
perfect for complicated case.

Maybe I should try to persist entities without cascade?

Regards,
Yu Wang

On Tue, Jun 23, 2009 at 2:17 AM, Miłosz Tylendamtyle...@o2.pl wrote:
 Hi!

 Also, you will find child  father ideas in thread [1]. The FAQ [2] 
 mentions it too.

 As for IDENTITY with Oracle, you could try the emulation feature [3]. It 
 emulates auto-increment columns by using triggers.

 Regards,
 Milosz

 [1] 
 http://n2.nabble.com/Inconsistent-behaviour-with-Bi-directional-One-to-Many-Mapping.-tp2570464p2570464.html
 [2] http://openjpa.apache.org/faq.html
 [3] 
 http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_dbsetup_dbsupport_oracle


 Hi,

 Which version of OpenJPA are you using?

 OpenJPA does not assume there are any constraints in the database unless you
 add the @ForeignKey annotation or configure OpenJPA to read constraints from
 the database. As a result we can sometimes do inserts out of order.. I tried
 to make this less likely to happen (without changing the underlying
 assumption about constraints) in OPENJPA-817 [1]. It isn't perfect but it
 should help for your scenario.

 [1] http://issues.apache.org/jira/browse/OPENJPA-817

 -mike

 On Mon, Jun 22, 2009 at 6:03 AM, wang yu  wrote:

  Hello,
  If I use GenerationType.AUTO or GenerationType.TABLE for PK field and
  let OpenJPA persist some entities cascade , in some cases, OpenJPA
  will try to persist child entity before the father entity.
  How to resolve this issue?
 
  I must use GenerationType.AUTO for oracle because it doesn't support
  GenerationType.IDENTITY naturally.
  Or do I have a chance to use  GenerationType.IDENTITY  for Pk fields
  of oracle database?
 
  I have attached the log information in attached file.
 
  Thanks!
 
  Regards,
  Yu Wang
 




Re: ID field auto generation issue for multiple databases supporting

2009-06-18 Thread wang yu
Hi Milosz,
Yes, you're right.  And I have checked the source code, the AUTO is
total identical with TABLE in OpenJPA.

Thank you for your patient help!

Regards,
Yu Wang

On Wed, Jun 17, 2009 at 6:02 PM, Miłosz Tylendamtyle...@o2.pl wrote:
 Hi Yu Wang,

 The error message seems to say Attempt to modify an identity column 'ID'. 
 Probably Derby does not allow you to insert a value to an identity column. I 
 suspect you have created the table when you had GenerationType.IDENTITY in 
 your entity. The table has been created with an identity column. Then you 
 changed the annotation to GenerationType.AUTO which made OpenJPA use a 
 sequence. However, the table definition did not change automatically and 
 OpenJPA tries to insert an explicit value to the identity column. Try to drop 
 the table and let OpenJPA create it again (or create it manualy but don't use 
 GENERATED BY DEFAULT AS IDENTITY with ID column). Hope this helps.

 Regards,
 Milosz



 Hello Milosz,
 I found OpenJpa created table OPENJPA_SEQUENCE_TABLE automatically in
 the runtime, following is a fragment of my log file:

 44048  xxx  TRACE  [Persistence-thread-0] openjpa.jdbc.SQL -  executing 
 prepstmnt 25906379 SELECT
 SEQUENCE_VALUE FROM xxx.OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE
 WITH RR [params=(int) 0]
 44047  xxx  TRACE  [Persistence-thread-0] openjpa.jdbc.SQL -  [0 ms] spent
 44063  xxx  TRACE  [Persistence-thread-0] openjpa.jdbc.SQL -  executing 
 prepstmnt 15975876 INSERT INTO
 xxx.OPENJPA_SEQUENCE_TABLE (ID, SEQUENCE_VALUE) VALUES (?, ?)
 [params=(int) 0, (int) 1]
 44078  xxx  TRACE  [Persistence-thread-0] openjpa.jdbc.SQL -  [15 ms] spent
 44078  xxx  TRACE  [Persistence-thread-0] openjpa.jdbc.SQL -  executing 
 prepstmnt 3112190 SELECT
 SEQUENCE_VALUE FROM xxx.OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE
 WITH RR [params=(int) 0]
 44078  xxx  TRACE  [Persistence-thread-0] openjpa.jdbc.SQL -  [0 ms] spent
 44094  xxx  TRACE  [Persistence-thread-0] openjpa.jdbc.SQL -  executing 
 prepstmnt 20716393 UPDATE
 xxx.OPENJPA_SEQUENCE_TABLE SET SEQUENCE_VALUE = ? WHERE ID = ? AND
 SEQUENCE_VALUE = ? [params=(long) 51, (int) 0, (long) 1]
 44094  xxx  TRACE  [Persistence-thread-0] openjpa.jdbc.SQL -  [0 ms] spent
 44188  xxx  TRACE  [Persistence-thread-0] openjpa.jdbc.SQL -  executing 
 prepstmnt 13686851 SELECT
 SEQUENCE_VALUE FROM xxx.OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE
 WITH RR [params=(int) 0]
 44203  xxx  TRACE  [Persistence-thread-0] openjpa.jdbc.SQL -  [0 ms] spent
 44203  xxx  TRACE  [Persistence-thread-0] openjpa.jdbc.SQL -  executing 
 prepstmnt 29070643 UPDATE
 xxx.OPENJPA_SEQUENCE_TABLE SET SEQUENCE_VALUE = ? WHERE ID = ? AND
 SEQUENCE_VALUE = ? [params=(long) 101, (int) 0, (long) 51]
 44203  xxx  TRACE  [Persistence-thread-0] openjpa.jdbc.SQL -  [0 ms] spent



 org.apache.openjpa.persistence.RollbackException: The transaction has
 been rolled back.  See the nested exceptions for details on the errors
 that occurred.
       at 
 org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:523)
       at 
 com.xxx.xxx.dao.DAOContainer.commitTransaction(DAOContainer.java:195)
       at com.xxx.xxx.ds.Persister.persist(Persister.java:221)
       at com.xxx.xxx.ds.PersistRunner.run(PersistRunner.java:49)
       at 
 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
       at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
       at java.util.concurrent.FutureTask.run(FutureTask.java:138)
       at 
 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
       at 
 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207)
       at 
 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
       at 
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
       at java.lang.Thread.run(Thread.java:619)
 Caused by:
 org.apache.openjpa.persistence.PersistenceException: The transaction
 has been rolled back.  See the nested exceptions for details on the
 errors that occurred.
       at 
 org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2163)
       at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
       at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
       at 
 org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1826)
       at 
 org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
       at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1350)
       at 
 org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:877)
       at 
 org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:512)
       ... 11 more
 Caused by:
 org.apache.openjpa.persistence.PersistenceException: 尝?修改标?列“ID”。
 {INSERT INTO xxx.MON_SERVICE (ID, ATTRIBUTES, 

Re: For oracle11g , setting openjpa.ConnectionUserName and openjpa.ConnectionPassword in java code error.

2009-06-17 Thread wang yu
Hi,
Anybody else has tried this?

Regards,
Yu Wang

On Thu, Jun 11, 2009 at 4:54 PM, wang yuwangy...@gmail.com wrote:
 Hi,
 I guess it's a bug of OpenJPA 1.2.1.
 I used ojdbc6.jar to connect oracle11g.

 If I pass username and password in persistence.xml, everything will be OK.
 But if I pass them from java code like below, the connecting will fail:
                map.put(openjpa.ConnectionUserName,tsam);
                map.put(openjpa.ConnectionPassword,tsam);

 And I analyzed the stack trace, the stack is completely identical with
 the case that I doesn't specify username and password for openjpa at
 all.
 And the stack is little different with using wrong username and password.

 Is it an OpenJPA and Oracle integration bug?

 Regards,
 Yu Wang



Re: ID field auto generation issue for multiple databases supporting

2009-06-14 Thread wang yu
Milosz,

I have tried @GeneratedValue(strategy=GenerationType.AUTO), it works
fine for oracle but doesn't work for Derby.

Regards,
Yu Wang

On Sat, Jun 13, 2009 at 7:19 PM, Miłosz Tylendamtyle...@o2.pl wrote:
 Yu Wang,

 Try using @GeneratedValue(strategy=GenerationType.AUTO). This should 
 automatically pick up either IDENTITY or SEQUENCE depending on the database 
 you are using.

 Cheers,
 Milosz

 Hello,
 I found If I user derby, I need to use
 @GeneratedValue(strategy=GenerationType.IDENTITY) for ID field.
 And for oracle database, I need to use
 @GeneratedValue(strategy=GenerationType.SEQUENCE).

 The question is if I want to use same entity classes to support both
 derby and oracle, how should I do?
 Do we have best practice for ID field value generation strategy for
 multiple databases supporting?

 Regards,
 Yu Wang




ID field auto generation issue for multiple databases supporting

2009-06-11 Thread wang yu
Hello,
I found If I user derby, I need to use
@GeneratedValue(strategy=GenerationType.IDENTITY) for ID field.
And for oracle database, I need to use
@GeneratedValue(strategy=GenerationType.SEQUENCE).

The question is if I want to use same entity classes to support both
derby and oracle, how should I do?
Do we have best practice for ID field value generation strategy for
multiple databases supporting?

Regards,
Yu Wang


Re: OpenJPA reconnect derby database issue.

2009-06-07 Thread wang yu
Hi Mike,
Following is how I close cache:

property name=openjpa.DataCache value=false /
property name=openjpa.QueryCache value=false /
property name=openjpa.jdbc.QuerySQLCache 
value=false /
property name=openjpa.QueryCompilationCache 
value=false /

Your concern is spring cache the EntityManager, right? How can I avoid
this? Should I use a brand new entityManagerFactory?

Regards,
Yu Wang


On Fri, Jun 5, 2009 at 9:56 PM, Michael Dickmichael.d.d...@gmail.com wrote:
 Hi Yu Wang,

 It sounds like someone is maintaining a pool of EntityManagers. The
 assertOpen method isn't checking Derby, it's concerned with the state of the
 EntityManager itself.

 How did you close the cache of OpenJPA EntityManagers? I have very little
 experience with Spring, but the stack makes it look like it's handing out
 the EntityManager that is being used.

 -mike

 On Fri, Jun 5, 2009 at 2:44 AM, wang yu wangy...@gmail.com wrote:

 Hello,
 My application uses Tomcat6,derby,spring and OpenJPA 1.20.
 My case is stopping derby database and restarting it. And I found even
 if I catch the database connection broken exception and create an new
 EntityManager successfully after derby restarts, the following
 exception stack will be printed :

 2009-06-05 15:22:21,140 ERROR com.***.ds.Persister.persist:203
 Persistence-thread-1 The context has been closed.  The stack trace
 at which the context was closed is available if Runtime=TRACE logging
 is enabl...@agent
 (key=Domain7:machine0:0,machine0;jsessionid=0F915CC5A079F150E6C1E34661661831)
 openjpa-1.2.1-r752877:753278 fatal user error
 org.apache.openjpa.persistence.InvalidStateException: The context has
 been closed.  The stack trace at which the context was closed is
 available if Runtime=TRACE logging is enabled.
        at
 org.apache.openjpa.kernel.BrokerImpl.assertOpen(BrokerImpl.java:4367)
        at
 org.apache.openjpa.kernel.BrokerImpl.beginOperation(BrokerImpl.java:1766)
        at
 org.apache.openjpa.kernel.BrokerImpl.newQuery(BrokerImpl.java:3483)
        at
 org.apache.openjpa.kernel.DelegatingBroker.newQuery(DelegatingBroker.java:1225)
        at
 org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:870)
        at
 org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:865)
        at
 org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:77)
        at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
        at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at
 org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:357)
        at $Proxy15.createQuery(Unknown Source)
        at
 com.***.dao.JPAImpl.CallpathDaoImpl.findByName(CallpathDaoImpl.java:31)
        at
 com.***.dao.JPAImpl.CallpathDaoImpl.findByName(CallpathDaoImpl.java:18)
        at com.***.ds.Persister.persist(Persister.java:139)
        at com.***.ds.PersistRunner.run(PersistRunner.java:44)
        at
 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
        at
 java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
        at java.util.concurrent.FutureTask.run(FutureTask.java:123)
        at
 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:65)
        at
 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:168)
        at
 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
        at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
        at java.lang.Thread.run(Thread.java:595)

 And I ensure the new EntityManager connect derby successfully by
 netstat -an|grep 1527.
 I closed all cache of OpenJPA but same error still happen.


 Regards,
 Yu Wang




OpenJPA reconnect derby database issue.

2009-06-05 Thread wang yu
Hello,
My application uses Tomcat6,derby,spring and OpenJPA 1.20.
My case is stopping derby database and restarting it. And I found even
if I catch the database connection broken exception and create an new
EntityManager successfully after derby restarts, the following
exception stack will be printed :

2009-06-05 15:22:21,140 ERROR com.***.ds.Persister.persist:203
Persistence-thread-1 The context has been closed.  The stack trace
at which the context was closed is available if Runtime=TRACE logging
is 
enabl...@agent(key=Domain7:machine0:0,machine0;jsessionid=0F915CC5A079F150E6C1E34661661831)
openjpa-1.2.1-r752877:753278 fatal user error
org.apache.openjpa.persistence.InvalidStateException: The context has
been closed.  The stack trace at which the context was closed is
available if Runtime=TRACE logging is enabled.
at org.apache.openjpa.kernel.BrokerImpl.assertOpen(BrokerImpl.java:4367)
at 
org.apache.openjpa.kernel.BrokerImpl.beginOperation(BrokerImpl.java:1766)
at org.apache.openjpa.kernel.BrokerImpl.newQuery(BrokerImpl.java:3483)
at 
org.apache.openjpa.kernel.DelegatingBroker.newQuery(DelegatingBroker.java:1225)
at 
org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:870)
at 
org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:865)
at 
org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:77)
at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at 
org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:357)
at $Proxy15.createQuery(Unknown Source)
at 
com.***.dao.JPAImpl.CallpathDaoImpl.findByName(CallpathDaoImpl.java:31)
at 
com.***.dao.JPAImpl.CallpathDaoImpl.findByName(CallpathDaoImpl.java:18)
at com.***.ds.Persister.persist(Persister.java:139)
at com.***.ds.PersistRunner.run(PersistRunner.java:44)
at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
at java.util.concurrent.FutureTask.run(FutureTask.java:123)
at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:65)
at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:168)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)

And I ensure the new EntityManager connect derby successfully by
netstat -an|grep 1527.
I closed all cache of OpenJPA but same error still happen.


Regards,
Yu Wang


Re: How to encrypt DB password in persistence.xml

2009-05-19 Thread wang yu
Kevin,
Thanks for your patient answer.
I'll try to resolve it in dbcp community.

Cheers,
Yu Wang

On Mon, May 18, 2009 at 9:03 PM, Kevin Sutter kwsut...@gmail.com wrote:
 Hi Yu Wang,
 My apologies, but I'm not an expert with DBCP.  I just thought I would do a
 quick Google search to see what's out there and I found a few hits, one of
 which I posted to my previous reply.  Since you seem to be interested in
 encrypting the password being sent in to DBCP, you will probably need to do
 something specific with the DBCP implementation either by modifying it
 directly (like you mentioned in one of your replies) or maybe by extending
 the BasicDataSource (my reference).  I don't have any direct experience with
 either approach.  You might want to try posting your question to the DBCP
 group [1].

 Please keep us informed of your progress.  Thanks.

 Kevin

 [1]  http://commons.apache.org/dbcp/

 On Mon, May 18, 2009 at 2:47 AM, wang yu wangy...@gmail.com wrote:

 Hi Kevin,
 Thanks.
 The link you gave indicate how to extend BasicDataSourceFactory. But I
 guess this approach isn't feasible for OpenJPA.
 I need to extend BasicDataSource directly, right?
 And you mentioned there were other instructions on extending the
 BasicDataSource. Can you make it clearer?I found extending
 BasicDataSource isn't very straightforward.

 Regards,
 Yu Wang

 On Fri, May 15, 2009 at 9:56 PM, Kevin Sutter kwsut...@gmail.com wrote:
  Hi Yu Wang,
  Or, you could develop an answer for OpenJPA and contribute it back to the
  project...  :-)  Providing an encryption capability for persistence.xml
  password values would be a nice feature.  But, this would probably only
  apply to our openjpa.* properties...
 
  In your particular case where you are passing in all of the parameters to
  dbcp, I don't see how OpenJPA could help in this case.  The URL is just
  passed through to dbcp, so any decryption of a password field would need
 to
  be provided by dbcp.
 
  I did a quick search on this topic and found a few hits related to
  encrypting passwords used for dbcp.  One link [1] indicated that using
  Tomcat 6.0 makes this a bit easier, but there were other instructions on
  extending the BasicDataSource.  This link was specific to Tomcat's
  server.xml, but the idea could probably be extended to the
 persistence.xml.
 
  Let us know what you come up with.
 
  Thanks,
  Kevin
 
  [1]
 
 http://stackoverflow.com/questions/129160/how-to-avoid-storing-passwords-in-the-clear-for-tomcats-server-xml-resource-defi
 
 
 
  On Fri, May 15, 2009 at 2:33 AM, wang yu wangy...@gmail.com wrote:
 
  Hi Kevin,
  Thank you. You had real good solutions but unfortunately neither of
  them is feasible for our project.
  We use Apache dbcp datasource to leverage DB connection pool and
  tomcat 5.5 as app server.
  Following is a fragment of our persistence.xml:
                         property name=openjpa.ConnectionDriverName
  value=org.apache.commons.dbcp.BasicDataSource /
 
                         property name=openjpa.ConnectionProperties
 
   value=driverClassName=org.apache.derby.jdbc.ClientDriver,
  url=jdbc:derby://localhost:1527/TSAM;create=true, username=app,
  password=app, maxActive=30, maxWait=1,
  poolPreparedStatements=true /
 
  How to encrypt password under  this situation? Or should I adopt
  alternative connection pool implementation to make password encryption
  easier?
 
  if no better solution, I guess I only have two choices
  1. Give up apache dbcp.
  2. Modify source code of apache dbcp.
 
  Regards,
  Yu Wang
 
 
 
 
  On Thu, May 14, 2009 at 10:54 PM, Kevin Sutter kwsut...@gmail.com
 wrote:
   Hi,
   JPA does not define this functionality.  You could pass in the
 password
  via
   the application instead of hard-coding it in a persistence.xml.  Or,
 if
  you
   are in an app server environment, you should use a jndi lookup of a
   datasource.  This would be the most secure.
  
   Kevin
  
   On Tue, May 12, 2009 at 4:31 AM, wang yu wangy...@gmail.com wrote:
  
   As title.
  
   Regards,
   Yu Wang
  
  
 
 




Re: How to encrypt DB password in persistence.xml

2009-05-18 Thread wang yu
Hi Kevin,
Thanks.
The link you gave indicate how to extend BasicDataSourceFactory. But I
guess this approach isn't feasible for OpenJPA.
I need to extend BasicDataSource directly, right?
And you mentioned there were other instructions on extending the
BasicDataSource. Can you make it clearer?I found extending
BasicDataSource isn't very straightforward.

Regards,
Yu Wang

On Fri, May 15, 2009 at 9:56 PM, Kevin Sutter kwsut...@gmail.com wrote:
 Hi Yu Wang,
 Or, you could develop an answer for OpenJPA and contribute it back to the
 project...  :-)  Providing an encryption capability for persistence.xml
 password values would be a nice feature.  But, this would probably only
 apply to our openjpa.* properties...

 In your particular case where you are passing in all of the parameters to
 dbcp, I don't see how OpenJPA could help in this case.  The URL is just
 passed through to dbcp, so any decryption of a password field would need to
 be provided by dbcp.

 I did a quick search on this topic and found a few hits related to
 encrypting passwords used for dbcp.  One link [1] indicated that using
 Tomcat 6.0 makes this a bit easier, but there were other instructions on
 extending the BasicDataSource.  This link was specific to Tomcat's
 server.xml, but the idea could probably be extended to the persistence.xml.

 Let us know what you come up with.

 Thanks,
 Kevin

 [1]
 http://stackoverflow.com/questions/129160/how-to-avoid-storing-passwords-in-the-clear-for-tomcats-server-xml-resource-defi



 On Fri, May 15, 2009 at 2:33 AM, wang yu wangy...@gmail.com wrote:

 Hi Kevin,
 Thank you. You had real good solutions but unfortunately neither of
 them is feasible for our project.
 We use Apache dbcp datasource to leverage DB connection pool and
 tomcat 5.5 as app server.
 Following is a fragment of our persistence.xml:
                        property name=openjpa.ConnectionDriverName
 value=org.apache.commons.dbcp.BasicDataSource /

                        property name=openjpa.ConnectionProperties

  value=driverClassName=org.apache.derby.jdbc.ClientDriver,
 url=jdbc:derby://localhost:1527/TSAM;create=true, username=app,
 password=app, maxActive=30, maxWait=1,
 poolPreparedStatements=true /

 How to encrypt password under  this situation? Or should I adopt
 alternative connection pool implementation to make password encryption
 easier?

 if no better solution, I guess I only have two choices
 1. Give up apache dbcp.
 2. Modify source code of apache dbcp.

 Regards,
 Yu Wang




 On Thu, May 14, 2009 at 10:54 PM, Kevin Sutter kwsut...@gmail.com wrote:
  Hi,
  JPA does not define this functionality.  You could pass in the password
 via
  the application instead of hard-coding it in a persistence.xml.  Or, if
 you
  are in an app server environment, you should use a jndi lookup of a
  datasource.  This would be the most secure.
 
  Kevin
 
  On Tue, May 12, 2009 at 4:31 AM, wang yu wangy...@gmail.com wrote:
 
  As title.
 
  Regards,
  Yu Wang
 
 




Re: How to encrypt DB password in persistence.xml

2009-05-15 Thread wang yu
Hi Kevin,
Thank you. You had real good solutions but unfortunately neither of
them is feasible for our project.
We use Apache dbcp datasource to leverage DB connection pool and
tomcat 5.5 as app server.
Following is a fragment of our persistence.xml:
property name=openjpa.ConnectionDriverName
value=org.apache.commons.dbcp.BasicDataSource /

property name=openjpa.ConnectionProperties

value=driverClassName=org.apache.derby.jdbc.ClientDriver,
url=jdbc:derby://localhost:1527/TSAM;create=true, username=app,
password=app, maxActive=30, maxWait=1,
poolPreparedStatements=true /

How to encrypt password under  this situation? Or should I adopt
alternative connection pool implementation to make password encryption
easier?

if no better solution, I guess I only have two choices
1. Give up apache dbcp.
2. Modify source code of apache dbcp.

Regards,
Yu Wang




On Thu, May 14, 2009 at 10:54 PM, Kevin Sutter kwsut...@gmail.com wrote:
 Hi,
 JPA does not define this functionality.  You could pass in the password via
 the application instead of hard-coding it in a persistence.xml.  Or, if you
 are in an app server environment, you should use a jndi lookup of a
 datasource.  This would be the most secure.

 Kevin

 On Tue, May 12, 2009 at 4:31 AM, wang yu wangy...@gmail.com wrote:

 As title.

 Regards,
 Yu Wang




How to encrypt DB password in persistence.xml

2009-05-12 Thread wang yu
As title.

Regards,
Yu Wang


Re: apache-openjpa-1.0.2 performance degrade under long-run press testing

2008-03-24 Thread wang yu
Kevin,Can you tell me how to replay a thread in openjpa? I didn't find any
link to reply a topic on the web page.

For openjap on tomcat issue, since tomcat is not a EE5 compliant application
server, we need enhance all entity class on the compilation time.
You can add enhancement action into your ant file like below:

taskdef name=openjpac
classname=org.apache.openjpa.ant.PCEnhancerTask
classpath refid=classpath /
/taskdef

target name=enhance depends=compile
openjpac
config
propertiesFile=${basedir}\WebContent\WEB-INF\classes\META-INF\persistence.xml/
classpath
pathelement location=${builddir}/
/classpath
fileset dir=${builddir} includes=$**/*.class/
/openjpac
/target

On Fri, Mar 14, 2008 at 11:03 AM, wang yu [EMAIL PROTECTED] wrote:

 Hello,
 I met one performance  issue with apache-openjpa-1.0.2.
 My environment includes apache-openjpa-1.0.2,db-derby-10.3.2.1-bin,and
 apache-tomcat-5.5.26.

 Below is the openjpa-related properties defined in the persistnce.xml:
 property name=openjpa.ConnectionDriverName value=
 org.apache.derby.jdbc.ClientDriver/
 property name=openjpa.ConnectionURL
 value=jdbc:derby://localhost:1527/tsam20-database;create=true/
 property name=openjpa.ConnectionUserName value=app/
 property name=openjpa.ConnectionPassword value=app/
 property name=openjpa.jdbc.SynchronizeMappings
 value=buildSchema/
 property name=openjpa.Log value=DefaultLevel=WARN,SQL=TRACE/

 And there is my main testing code:
 EntityManagerFactory factory = (EntityManagerFactory)
 servlet_context.getAttribute(FACTORY);
 EntityManager em = null;
 try {
 em = factory.createEntityManager();
 for (int i = 0; i  100; i++) {
 em.getTransaction().begin();
 for (int j = 0; j  100; j++) {
 MyMessage m = new MyMessage(Hello Persistence!+j);
 em.persist(m);
 }
 System.out.print(#);
 em.getTransaction().commit();
 em.clear();
 }
 } catch (Exception e) {
 if (em != null)
 em.getTransaction().rollback();
 e.printStackTrace();
 } finally {
 em.close();
 }

 I noticed if I run openjpa in a j2se env, the performance is very good and
 keeps steady for long time.

 But If I run openjpa persisting in a tomcat container, the performance
 degrades after half an hour and the java process will be totally fronzen
 after one or two hour.

 Does anybody have ideas about this issue? If there's some tips about how
 to use openjpa in a j2ee application? Or, I should use a more
 enterprise-grade DB server like oracle?

 Regards,
 Yu Wong







Re: apache-openjpa-1.0.2 performance degrade under long-run press testing

2008-03-19 Thread wang yu
the problem is resolved.

On Fri, Mar 14, 2008 at 11:03 AM, wang yu [EMAIL PROTECTED] wrote:

 Hello,
 I met one performance  issue with apache-openjpa-1.0.2.
 My environment includes apache-openjpa-1.0.2,db-derby-10.3.2.1-bin,and
 apache-tomcat-5.5.26.

 Below is the openjpa-related properties defined in the persistnce.xml:
 property name=openjpa.ConnectionDriverName value=
 org.apache.derby.jdbc.ClientDriver/
 property name=openjpa.ConnectionURL
 value=jdbc:derby://localhost:1527/tsam20-database;create=true/
 property name=openjpa.ConnectionUserName value=app/
 property name=openjpa.ConnectionPassword value=app/
 property name=openjpa.jdbc.SynchronizeMappings
 value=buildSchema/
 property name=openjpa.Log value=DefaultLevel=WARN,SQL=TRACE/

 And there is my main testing code:
 EntityManagerFactory factory = (EntityManagerFactory)
 servlet_context.getAttribute(FACTORY);
 EntityManager em = null;
 try {
 em = factory.createEntityManager();
 for (int i = 0; i  100; i++) {
 em.getTransaction().begin();
 for (int j = 0; j  100; j++) {
 MyMessage m = new MyMessage(Hello Persistence!+j);
 em.persist(m);
 }
 System.out.print(#);
 em.getTransaction().commit();
 em.clear();
 }
 } catch (Exception e) {
 if (em != null)
 em.getTransaction().rollback();
 e.printStackTrace();
 } finally {
 em.close();
 }

 I noticed if I run openjpa in a j2se env, the performance is very good and
 keeps steady for long time.

 But If I run openjpa persisting in a tomcat container, the performance
 degrades after half an hour and the java process will be totally fronzen
 after one or two hour.

 Does anybody have ideas about this issue? If there's some tips about how
 to use openjpa in a j2ee application? Or, I should use a more
 enterprise-grade DB server like oracle?

 Regards,
 Yu Wong