[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] OSGi and Persistence

Hi Peter,

I don't know if you are interested in none standard mapping technologies.

We are using EMF for our domain models and have written our custom
mapping (generated out of a DSL).

The main structure of usage can be seen in [1] and working similar to
MyBatis but the idea is:
a) each domain object has a Mapper-Interface [2]
b) the mapper interface with the database (select,update,insert,delete)
c) the mappers internally communicate e.g. to lazily load attributes
   see e.g. [3]

The nice thing about it is that domain code only knows the mapper &
domain objects but has no idea how the mapping to the database really works.

The complete system is using OSGi-Services for configuration (e.g.
db-connection), extensions (which mappers are available) and
customization (use a different connection pooling tech, caching lib,
bytecode weaver, ...).

There are currently 2 "hacks" to run on OSGi:
* c3p0 does not allow me to set a classloader to load the SQL-Driver so
  i had to create a fragement to get the JDBC-Driver in.
* cglib would use the wrong classpath so we are setting our customer
  classloader

In our case we have a DSL to generate the mappers from them e.g.[4] for
the Person mapping but one could write this by hand if someone wants to ;-)

Like I said it's fairly special solution but works very well for us
maybe it is interesting to you. For is improved performance & memory
footprint against Hibernate which we used before significantly!

Tom

[1]https://github.com/BestSolution-at/emap/blob/master/at.bestsolution.persistence.sample/src/at/bestsolution/persistence/sample/ContactBookSample.java
[2]https://github.com/BestSolution-at/emap/tree/master/at.bestsolution.persistence.sample.model.emap/src-gen/sample
[3]https://github.com/BestSolution-at/emap/blob/master/at.bestsolution.persistence.sample.model.emap/src-gen/sample/java/PersonMapperFactory.java
[4]https://github.com/BestSolution-at/emap/blob/master/at.bestsolution.persistence.sample.model.emap/src/sample/Person.emap

On 25.11.13 13:41, Peter Kriens wrote:
> I am doing some research on OSGi and persistence and I find the whole Java persistence story quite confusing and complex. Part of my problem is that I see lots of frameworks but it is quite hard to see code that really uses those frameworks. Virtually all tutorials and examples look highly contrived and seem to totally ignore issues like caching, security and seem to be rather lax concerning transactions.  
> 
> I wonder if people in this forum could share with me a typical production source file showing:
> 
> 	How entities are defined
> 	The persistent use of the entity, i.e. the part where the SQL will be generated. I.e. places where the PersistenceManager, EntityManager, SQL generation is used
> 	How results are cached
> 
> A single source or class file per issue is best. Adding a small description how you use persistence (Aries, JPA, JDO, JDBC, etc), the primary issues you face, and describe your environment is highly appreciated. 
> 
> I know from my own experience that there is often a feeling that your own code is not up for showing to others but please send me the raw unadulterated code; I need to see how it is today, not how you think it should be. Obviously I am not interested in what the code does or where it is used so feel free to remove comments (if any!) and change names. I am just looking for a couple of hundred of real world samples to extract the patterns that are actually popular in our industry. 
> 
> Obviously I will not share that code with anyone and treat it fully confidential. Also would appreciate a little description how you use persistence in OSGi.
> 
> So in this case, do not ask what the OSGi can do for you, but for once, ask what you can do for the OSGi! ;-)
> 
> Please? Come on, it only takes 3 minutes. Send your 4 files to: Peter.Kriens@xxxxxxxxx
> 
> Kind regards,
> 
> 	Peter Kriens
> 
> 
> 
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>