tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: tomee configuration -- persistence.xml -- persistence unit definition.
Date Thu, 08 Oct 2015 13:15:25 GMT
Hi,


TomEE has a flag to fail if there is no 1-1 matching between
persistence.xml and datasources definition but by default it tries to find
the adapted datasource (just awesome in tests and often nice for 1 server =
1 application deployments).

Idea is to find a datasource looking like the one you want in the
persistence.xml (respecting jta/non-jta constraint).

All is written int he logs: "Auto-adjusting....".



Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-10-08 14:51 GMT+02:00 martin mucha <alfonz19@gmail.com>:

> Hi,
>
> can someone explain to me, how persistence works in tomee? For example from
> sample project moviefun-rest: There's referenced inexisting persistence
> unit
> in persistence.xml, but app still works. And there's is datasource defined
> in tomee.xml, which is not used. I'd expect app to fail when referencing
> inexisting datasource. Ok, but I've fixed both jta and non-jta to point at
> defined datasource. It still works, file-based hsqldb is created, however
> nothing is persisted into it. Weird. So can someone please spell some light
> on this 'funny' example? Or share a link to actually working, commented
> example?
>
> thanks.
>
> persistence.xml:
>
> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
>              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>              xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
>   <persistence-unit name="movie-unit">
>     <jta-data-source>movieDatabase</jta-data-source>
>     <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
>     <class>org.superbiz.moviefun.Movie</class>
>
>     <properties>
>       <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)"/>
>     </properties>
>   </persistence-unit>
> </persistence>
>
>
> tomee.xml:
> <tomee>
>   <Resource id="HSQLDB Database" type="DataSource">
>     JdbcDriver org.hsqldb.jdbcDriver
>     JdbcUrl jdbc:hsqldb:file:target/db/moviefun
>     UserName sa
>     Password
>   </Resource>
> </tomee>
>
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/tomee-configuration-persistence-xml-persistence-unit-definition-tp4676445.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message