Lachlan,
I forgot to answer your 2nd question
about the warnings you received.
WARNING:
PersistenceUnitInfo marktwo-ejbPU has transactionType RESOURCE_LOCAL and
therefore jtaDataSource will be ignored
It looks like your
persistence.xml may be referencing a JNDI JTA DataSource, this warning
is normal if you don't specify a non-default transaction-type="JTA" in your
persistence-unit element - programmatic SE persistence units default to
RESOURCE_LOCAL as well.
In the dynamic example all database
parameters are hardcoded in
EclipseLinkJPATest.getEMFProperties().
If you take out
the following line from your persistence.xml that points to a datasource on your
app server the warnings will go away.
<jta-data-source>yourAppServerJTADS</jta-data-source>
Persisting:
-------------------
I added a persist command to
the example during creation to also write to the db to reproduce your
issue. @PersistenceContext(unitName = "employee") public class
TransactionExamples extends EclipseLinkJPATest { public void
createNewObject() throws Exception {
assertEquals(0.0d,
newEmp.get("salary")); new->
em.persist(newEmp);
If I add transaction-type
(defaults to RESOURCE_LOCAL) and jta-data-source elements to the pu - we get
warnings about use of JTA resources. This is normal since you usually would
specify jdbc.driver|url|user|passsword and target-database when you are not
using a JNDI JTA or non-JTA DataSource. See the following changes to the pu
in the example.
With
warning -----------------
[EL Warning]: PersistenceUnitInfo
employee has transactionType RESOURCE_LOCAL and therefore jtaDataSource will be
ignored [EL Info]: EclipseLink, version: Eclipse Persistence Services - 1.0
(Build SNAPSHOT - 20080708) .... [EL Fine]: Connection(22700073)--SELECT
COUNT(EMP_ID) FROM DYNAMIC_EMP [EL Fine]: Connection(15081425)--INSERT INTO
DYNAMIC_EMP (EMP_ID, F_NAME, L_NAME, SALARY) VALUES (?, ?, ?, ?) bind
=> [111222333, Doug, Clarke, 0.0] [EL Config]:
Connection(22700073)--disconnect [EL Info]:
file:/C:/view_w34/examples/org.eclipse.persistence.example.jpa.dynamic/classes/-employee
logout successful
>clean DB DELETE FROM
"SCOTT"."DYNAMIC_EMP" WHERE ROWID = 'AAArgqAAEAAAChMAAL' AND ORA_ROWSCN =
'20611732' and /* workaround for base db bug */( EMP_ID is null or EMP_ID is not
null ) Commit Successful
Without
warning -------------------
[EL Info]: EclipseLink, version:
Eclipse Persistence Services - 1.0 (Build SNAPSHOT - 20080708) ... [EL
Info]:
file:/C:/view_w34/examples/org.eclipse.persistence.example.jpa.dynamic/classes/-employee
login successful [EL Fine]: Connection(18346782)--SELECT COUNT(EMP_ID) FROM
DYNAMIC_EMP [EL Fine]: Connection(18346782)--SELECT MIN(EMP_ID) FROM
DYNAMIC_EMP [EL Fine]: Connection(12245160)--SELECT EMP_ID, F_NAME, L_NAME,
SALARY FROM DYNAMIC_EMP WHERE (EMP_ID = ?) FOR UPDATE bind =>
[1] [EL Fine]: Connection(12245160)--UPDATE DYNAMIC_EMP SET F_NAME = ? WHERE
(EMP_ID = ?) bind => [Bob++++, 1] [EL Fine]:
Connection(18346782)--SELECT COUNT(EMP_ID) FROM DYNAMIC_EMP [EL Fine]:
Connection(12245160)--INSERT INTO DYNAMIC_EMP (EMP_ID, F_NAME, L_NAME, SALARY)
VALUES (?, ?, ?, ?) bind => [111222333, Doug, Clarke, 0.0] [EL
Config]: Connection(18346782)--disconnect [EL Info]:
file:/C:/view_w34/examples/org.eclipse.persistence.example.jpa.dynamic/classes/-employee
logout successful
thank you
/michael
Tim,
Lachlan,
Hi, this temporary code until bug#
225321 is fixed should in the case that you are running in eclipse - point to
the package-root classes directory that would contain the both the dynamic
persistence generation classes and the META-INF/persistence.xml -
required to define non-Entity configuration properties). If you are
running your persistence unit from a jar then it should be a url to that
jar.
"file:/C:/view_w34/examples/org.eclipse.persistence.example.jpa.dynamic/classes/"));
My
understanding so far of this example is that it generates an Entity
(DYNAMIC_EMP) at runtime in memory without a predefined @Entity class on
disk. An advantage of this would be that one could define the
attributes programmatically via XML - this closely follows the dynamic
API part of SDO (Service Data Objects) in our sdo
subproject.
You may reference the corresponding Wiki page by the
example author at...
thank you
/michael
logs --------------------------------------------------------------------------------------
QueryExamples:
[EL Info]:
EclipseLink, version: Eclipse Persistence Services - @VERSION@ (Build
@BUILD_NUMBER@) [EL Fine]: Detected Vendor platform:
org.eclipse.persistence.platform.database.oracle.Oracle10Platform [EL
Config]:
Connection(14247437)--connecting(DatabaseLogin( platform=>Oracle10Platform user
name=> "scott" datasource URL="" "jdbc:oracle:thin:@10.....:1521:ORCL" )) [EL Config]:
Connection(8461448)--Connected:
jdbc:oracle:thin:@10.156.53.19.:1521:ORCL User:
SCOTT Database: Oracle Version: Oracle Database 10g Enterprise
Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and
Data Mining options Driver: Oracle JDBC driver Version:
11.1.0.0.0-Beta5 [EL Config]:
Connection(7888229)--connecting(DatabaseLogin( platform=>Oracle10Platform user
name=> "scott" datasource URL="" "jdbc:oracle:thin:@10...:1521:ORCL" )) [EL Config]:
Connection(22279806)--Connected:
jdbc:oracle:thin:@10.156.53.19.:1521:ORCL User:
SCOTT Database: Oracle Version: Oracle Database 10g Enterprise
Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and
Data Mining options Driver: Oracle JDBC driver Version:
11.1.0.0.0-Beta5 [EL Info]:
file:/C:/view_w34/examples/org.eclipse.persistence.example.jpa.dynamic/classes/-dynamic
login successful [EL Fine]: Connection(8461448)--DROP TABLE
DYNAMIC_EMP [EL Fine]: Connection(8461448)--CREATE TABLE DYNAMIC_EMP
(EMP_ID NUMBER(10) NOT NULL, F_NAME VARCHAR2(255) NULL, L_NAME VARCHAR2(255)
NULL, SALARY NUMBER(19,4) NULL, PRIMARY KEY (EMP_ID)) [EL Fine]:
Connection(8461448)--SELECT EMP_ID, F_NAME, L_NAME, SALARY FROM DYNAMIC_EMP
WHERE (EMP_ID = ?) bind => [1] [EL Fine]:
Connection(22279806)--INSERT INTO DYNAMIC_EMP (EMP_ID, F_NAME, L_NAME, SALARY)
VALUES (?, ?, ?, ?) bind => [1, John, Doe, 0.0] [EL Fine]:
Connection(8461448)--SELECT EMP_ID, F_NAME, L_NAME, SALARY FROM DYNAMIC_EMP
WHERE ((F_NAME = ?) AND (L_NAME = ?)) bind => [John, Doe] [EL
Config]: Connection(8461448)--disconnect [EL Info]:
file:/C:/view_w34/examples/org.eclipse.persistence.example.jpa.dynamic/classes/-dynamic
logout successful [EL Config]: Connection(14247437)--disconnect [EL
Config]: Connection(22279806)--disconnect
TransactionExamples:
[EL Info]: EclipseLink, version: Eclipse Persistence
Services - @VERSION@ (Build @BUILD_NUMBER@) [EL Fine]: Detected Vendor
platform:
org.eclipse.persistence.platform.database.oracle.Oracle10Platform [EL
Config]:
Connection(17089909)--connecting(DatabaseLogin( platform=>Oracle10Platform user
name=> "scott" datasource URL=""
"jdbc:oracle:thin:@10...:1521:ORCL" )) [EL Config]:
Connection(14314484)--Connected:
jdbc:oracle:thin:@10.156.53.19.:1521:ORCL User:
SCOTT Database: Oracle Version: Oracle Database 10g Enterprise
Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and
Data Mining options Driver: Oracle JDBC driver Version:
11.1.0.0.0-Beta5 [EL Config]:
Connection(31820984)--connecting(DatabaseLogin( platform=>Oracle10Platform user
name=> "scott" datasource URL=""
"jdbc:oracle:thin:@10...:1521:ORCL" )) [EL Config]:
Connection(12182618)--Connected:
jdbc:oracle:thin:@10.156.53.19.:1521:ORCL User:
SCOTT Database: Oracle Version: Oracle Database 10g Enterprise
Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and
Data Mining options Driver: Oracle JDBC driver Version:
11.1.0.0.0-Beta5 [EL Info]:
file:/C:/view_w34/examples/org.eclipse.persistence.example.jpa.dynamic/classes/-employee
login successful [EL Fine]: Connection(14314484)--SELECT COUNT(EMP_ID) FROM
DYNAMIC_EMP [EL Fine]: Connection(14314484)--SELECT MIN(EMP_ID) FROM
DYNAMIC_EMP [EL Fine]: Connection(12182618)--SELECT EMP_ID, F_NAME, L_NAME,
SALARY FROM DYNAMIC_EMP WHERE (EMP_ID = ?) FOR UPDATE bind =>
[1] [EL Fine]: Connection(12182618)--UPDATE DYNAMIC_EMP SET F_NAME = ?
WHERE (EMP_ID = ?) bind => [Bob++, 1] [EL Fine]:
Connection(14314484)--SELECT COUNT(EMP_ID) FROM DYNAMIC_EMP [EL Config]:
Connection(14314484)--disconnect [EL Info]:
file:/C:/view_w34/examples/org.eclipse.persistence.example.jpa.dynamic/classes/-employee
logout successful [EL Config]: Connection(17089909)--disconnect [EL
Config]:
Connection(12182618)--disconnect
On 07/07/2008, at 4:37 PM, Tim Hollosy wrote:
I've never done this, but from glancing at the bug report I
think you'd want to point it to the location of your classes directory
(the directory where your entity .class files are).
I'm not sure
if that's just your /classes or /bin or if you need to go down to the
package level.
Hi Tim,
I think it turns out that it is looking for the persistence.xml... not
100% as still get warnings?
here is the output of my first semi-successful test
so needless to say fairly happy...
Database changed
mysql> show tables;
+-------------------+
| Tables_in_marktwo |
+-------------------+
| DYNAMIC_EMP |
+-------------------+
1 row in set (0.00 sec)
mysql> select * from dynamic_emp;
+-----------+--------+--------+--------+
| EMP_ID | F_NAME | L_NAME | SALARY |
+-----------+--------+--------+--------+
| 111222333 | Doug | Clarke | 0
|
+-----------+--------+--------+--------+
1 row in set (0.00 sec)
mysql>
So far i am liking Eclipselink....
i am however getting a warning when i run this test to both create the
entity and persist ?
Jul 7, 2008 9:56:32 PM
org.eclipse.persistence.session.file:/Users/home/workspace/yggdrasil/on_server/marktwo/marktwo-ejb/dist/marktwo-ejb.jar-marktwo-ejbPU.transaction
WARNING: PersistenceUnitInfo
marktwo-ejbPU has transactionType RESOURCE_LOCAL and therefore jtaDataSource
will be ignored
Jul 7, 2008 9:56:32 PM
org.eclipse.persistence.session.file:/Users/home/workspace/yggdrasil/on_server/marktwo/marktwo-ejb/dist/marktwo-ejb.jar-marktwo-ejbPU
INFO: EclipseLink, version:
Eclipse Persistence Services - 1.0 (Build SNAPSHOT - 20080625)
Jul 7, 2008 9:56:32 PM
org.eclipse.persistence.session.file:/Users/home/workspace/yggdrasil/on_server/marktwo/marktwo-ejb/dist/marktwo-ejb.jar-marktwo-ejbPU
INFO: Server:
unknown
Jul 7, 2008 9:56:32 PM
org.eclipse.persistence.session.file:/Users/home/workspace/yggdrasil/on_server/marktwo/marktwo-ejb/dist/marktwo-ejb.jar-marktwo-ejbPU
INFO:
file:/Users/home/workspace/yggdrasil/on_server/marktwo/marktwo-ejb/dist/marktwo-ejb.jar-marktwo-ejbPU
login successful
any ideas would
be appreciated...
thanks,
-lachlan
Hope that helps :) /tim On Mon, Jul 7, 2008 at
6:41 PM, Lachlan Gregor < lachlan.gregor@xxxxxxxxx>
wrote:
Hi,
I have a question regarding dynamic entities
(which i think is awesome, and
helps answer an issue that has had me trolling
the net for the last few
weeks, and thus led me to Eclipselink, not to
mention increased performance
which i am also looking forward too).. I am just
trying to run some of the
example code however running into an issue with
:
// This root URL config should go away when bug
225321 is fixed
puInfo.setPersistenceUnitRootUrl(new
URL("file:/C:/Eclipse/EclipseLink/trunk/examples/org.eclipse.persistence.example.jpa.dynamic/classes/"));
I am just wondering what the url is meant to be
pointing at in particular?
any help would be great,
thanks,
-lachlan
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
--
./tch _______________________________________________ eclipselink-users
mailing list eclipselink-users@xxxxxxxxxxxhttps://dev.eclipse.org/mailman/listinfo/eclipselink-users
|