<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://batmat.net/blog/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Blogounage - hibernate</title>
  <link>http://batmat.net/blog/</link>
  <description></description>
  <language>fr</language>
  <pubDate>Sat, 28 Jan 2012 08:26:48 +0100</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>How to retrieve the Hibernate Session from the EntityManager interface</title>
    <link>http://batmat.net/blog/post/2008/07/13/How-to-retrieve-the-Hibernate-Session-from-the-EntityManager-interface</link>
    <guid isPermaLink="false">urn:md5:318777f7c82d121b408a1abb41df548f</guid>
    <pubDate>Sun, 13 Jul 2008 23:42:00 +0200</pubDate>
    <dc:creator>batmat</dc:creator>
        <category>Technique</category>
        <category>ejb3</category><category>hibernate</category><category>java</category><category>jpa</category>    
    <description>    &lt;p&gt;Well, as I myself fell into this stupid gap, I guess I'll try to help. I was quite pushed in this trap by a fallacious part of the &lt;a href=&quot;http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html/hibernate.html#d0e241&quot; hreflang=&quot;en&quot;&gt;jboss documentation&lt;/a&gt; :&lt;/p&gt;
&lt;pre class=&quot;geshi&quot;&gt;&lt;code class=&quot;java&quot;&gt;@PersistenceContext EntityManager entityManager;&lt;br /&gt;
&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; someMethod&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; org.&lt;span class=&quot;me1&quot;&gt;jboss&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ejb3&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;entity&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;HibernateSession&lt;/span&gt; hs = &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;HibernateSession&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;entityManager;&lt;br /&gt;
&amp;nbsp; org.&lt;span class=&quot;me1&quot;&gt;hibernate&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Session&lt;/span&gt; session = hs.&lt;span class=&quot;me1&quot;&gt;getHibernateSession&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;strong&gt;Let's be clear : this is totally WRONG!&lt;/strong&gt; Yes, it will work under JBoss, but as there's a standard way to do this, this is not the right way to do this.&lt;/p&gt;


&lt;p&gt;In fact, there's a dedicated method that lets you retrieve the underlying persistence manager : &lt;em&gt;EntityManager.getDelegate()&lt;/em&gt;. If you read this method's javadoc, you'll see the following :&lt;/p&gt;

&lt;pre class=&quot;geshi&quot;&gt;&lt;code class=&quot;java&quot;&gt;&lt;span class=&quot;coMULTI&quot;&gt;/**&lt;br /&gt;
&amp;nbsp;* Return the underlying provider object for the EntityManager,&lt;br /&gt;
&amp;nbsp;* if available. The result of this method is implementation&lt;br /&gt;
&amp;nbsp;* specific.&lt;br /&gt;
&amp;nbsp;* @throws IllegalStateException if this EntityManager has been closed.&lt;br /&gt;
&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3AObject+java.sun.com&amp;amp;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;Object&lt;/span&gt;&lt;/a&gt; getDelegate&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;And the &quot;underlying provider&quot;, for Hibernate, is obviously the Hibernate &lt;em&gt;Session&lt;/em&gt; instance...&lt;/p&gt;


&lt;p&gt;So, the right way to retrieve the Session is something like the following instead :&lt;/p&gt;

&lt;pre class=&quot;geshi&quot;&gt;&lt;code class=&quot;java&quot;&gt;@PersistenceContext EntityManager entityManager;&lt;br /&gt;
&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; someMethod&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; org.&lt;span class=&quot;me1&quot;&gt;hibernate&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Session&lt;/span&gt; session = &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Session&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;entityManager.&lt;span class=&quot;me1&quot;&gt;getDelegate&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Under JBoss, using this code won't make a big difference. But using the standard way will let you run your code under several appservers (namely, it works like a charm&lt;sup&gt;[&lt;a href=&quot;http://batmat.net/blog/post/2008/07/13/#pnote-293-1&quot; id=&quot;rev-pnote-293-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt; under JBoss 4.2.2.ga and Glassfishv2ur1 for example). If you use the bad way above, this will just crash under Glassfish, for example...&lt;/p&gt;


&lt;p&gt;I reported the &lt;a href=&quot;http://jira.jboss.com/jira/browse/JBDOCS-282&quot;&gt;corresponding documentation bug in the JBOSS tracker&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Hope this helps...&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://batmat.net/blog/post/2008/07/13/#rev-pnote-293-1&quot; id=&quot;pnote-293-1&quot;&gt;1&lt;/a&gt;] ça, c'est pour Seb&lt;/p&gt;&lt;/div&gt;
</description>
    
    
    
          <comments>http://batmat.net/blog/post/2008/07/13/How-to-retrieve-the-Hibernate-Session-from-the-EntityManager-interface#comment-form</comments>
      <wfw:comment>http://batmat.net/blog/post/2008/07/13/How-to-retrieve-the-Hibernate-Session-from-the-EntityManager-interface#comment-form</wfw:comment>
      <wfw:commentRss>http://batmat.net/blog/feed/rss2/comments/293</wfw:commentRss>
      </item>
    
  <item>
    <title>Quelques déclarations XSD ou DTD de formats XML connus</title>
    <link>http://batmat.net/blog/post/2008/06/24/Quelques-declarations-XSD-ou-DTD-de-formats-XML-connus</link>
    <guid isPermaLink="false">urn:md5:b243873cbfb7b3a8b3b4e894449c6694</guid>
    <pubDate>Tue, 24 Jun 2008 18:44:00 +0200</pubDate>
    <dc:creator>batmat</dc:creator>
        <category>Technique</category>
        <category>dtd</category><category>hbm.xml</category><category>hibernate</category><category>maven</category><category>pom</category><category>spring</category><category>xsd</category>    
    <description>    &lt;p&gt;C'est le genre de chose qu'il est sympathique d'avoir écrit en tête de ce type de fichier pour disposer de l'auto-complétion XML dans son IDE favori.
Lorsque j'utilise un nouveau format XML, la première chose que je cherche est en effet à ajouter cet entête pour me faciliter la vie (et aux autres une fois &lt;em&gt;commité&lt;/em&gt; :)).&lt;/p&gt;


&lt;p&gt;Note&amp;nbsp;: dans la liste ci-dessous, je ne mets pas le prologue XML pour gagner en concision. Toutefois, ça ne fait jamais de mal de le mettre. Personnellement j'essaie de le mettre systématiquement.&lt;/p&gt;


&lt;h3&gt;Hibernate&amp;nbsp;: mappings hbm.xml&lt;/h3&gt;

&lt;p&gt;Même s'il vaut mieux à mon avis passer aux annotations lorsqu'on en a la possibilité, voici une déclaration de DTD qui fonctionne chez moi pour ceux qui ont encore des mappings hibernate à la sauce XML :&lt;/p&gt;

&lt;pre class=&quot;geshi&quot;&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;sc0&quot;&gt;&amp;lt;!DOCTYPE hibernate-mapping PUBLIC &amp;quot;-//Hibernate/Hibernate Mapping DTD 3.0//EN&amp;quot; &lt;br /&gt;
&amp;quot;http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;hibernate&lt;/span&gt;-mapping &lt;span class=&quot;re0&quot;&gt;package&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;net.batmat.domaine&amp;quot;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/hibernate&lt;/span&gt;-mapping&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;h3&gt;Java Persistence&amp;nbsp;: persistence.xml&lt;/h3&gt;

&lt;p&gt;Pour ceux qui utilisent &lt;a href=&quot;http://java.sun.com/javaee/technologies/persistence.jsp&quot; hreflang=&quot;en&quot;&gt;Java Persistence&lt;/a&gt;, cette &quot;sous-spécification&quot; des EJB3 devenue une spécification autonome dans sa version 2 :&lt;/p&gt;

&lt;pre class=&quot;geshi&quot;&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;persistence&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;xmlns&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;http://java.sun.com/xml/ns/persistence&amp;quot;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns:&lt;span class=&quot;re0&quot;&gt;xsi&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xsi:&lt;span class=&quot;re0&quot;&gt;schemaLocation&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; http://java.sun.com/xml/ns/persistence&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd&amp;quot;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;re0&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/persistence&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;h3&gt;Spring&amp;nbsp;: fichier de contexte XML&lt;/h3&gt;

&lt;p&gt;Depuis la version 2, ils ont subdivisé leur format XML en différents namespaces. Voici un exemple fonctionnel qui met en œuvre un certain nombre de ces espaces de nommages XML. Je laisse en exercice le passage à Spring 2.5 (que nous utilisons, d'ailleurs, mais on n'a pas mis à jour le XML) ou l'ajout d'un autre namespace dont vous auriez besoin :-).&lt;/p&gt;

&lt;pre class=&quot;geshi&quot;&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;xmlns&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns:&lt;span class=&quot;re0&quot;&gt;xsi&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns:&lt;span class=&quot;re0&quot;&gt;util&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;http://www.springframework.org/schema/util&amp;quot;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns:&lt;span class=&quot;re0&quot;&gt;aop&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;http://www.springframework.org/schema/aop&amp;quot;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns:&lt;span class=&quot;re0&quot;&gt;tx&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;http://www.springframework.org/schema/tx&amp;quot;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xsi:&lt;span class=&quot;re0&quot;&gt;schemaLocation&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; http://www.springframework.org/schema/beans&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; http://www.springframework.org/schema/util&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; http://www.springframework.org/schema/util/spring-util-2.0.xsd&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; http://www.springframework.org/schema/tx&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; http://www.springframework.org/schema/tx/spring-tx-2.0.xsd&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; http://www.springframework.org/schema/aop&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; http://www.springframework.org/schema/aop/spring-aop-2.0.xsd&amp;quot;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/beans&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;h3&gt;Maven&amp;nbsp;: pom.xml&lt;/h3&gt;

&lt;p&gt;Celui-là, il est sacrément pratique vu la taille du truc :&lt;/p&gt;

&lt;pre class=&quot;geshi&quot;&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;project&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;xmlns&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;http://maven.apache.org/POM/4.0.0&amp;quot;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns:&lt;span class=&quot;re0&quot;&gt;xsi&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xsi:&lt;span class=&quot;re0&quot;&gt;schemaLocation&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;http://maven.apache.org/POM/4.0.0&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; http://maven.apache.org/maven-v4_0_0.xsd&amp;quot;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/project&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Voilà déjà pour cette fois. Une fois cet entête ajouté, dans Eclipse par exemple, tapez juste &quot;&amp;lt;&quot; quelque part et vous verrez la liste des balises apparaître et leur documentation si les auteurs l'ont indiquée (après qu'Eclipse ait pu récupérer le XSD sur Internet, bien sûr) :
&lt;img src=&quot;http://batmat.net/dotclear/public/images/auto-completion-xml-eclipse.png&quot; alt=&quot;Auto-complétion du XML avec Eclipse&quot; style=&quot;display:block; margin:0 auto;&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Si vous en avez d'autres, n'hésitez pas à les poster (ou à les demander, si je suis dans un bon jour) dans les commentaires.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Update 01/10/2008&lt;/strong&gt;, ajout du application.xml des &lt;a href=&quot;http://fr.wikipedia.org/wiki/EAR_(format_de_fichier)&quot;&gt;EAR&lt;/a&gt; :&lt;/p&gt;
&lt;pre class=&quot;geshi&quot;&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;sc0&quot;&gt;&amp;lt;!DOCTYPE application PUBLIC &amp;quot;-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN&amp;quot; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;quot;http://java.sun.com/dtd/application_1_3.dtd&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;application&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;quot;mon appli&amp;quot;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/application&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</description>
    
    
    
          <comments>http://batmat.net/blog/post/2008/06/24/Quelques-declarations-XSD-ou-DTD-de-formats-XML-connus#comment-form</comments>
      <wfw:comment>http://batmat.net/blog/post/2008/06/24/Quelques-declarations-XSD-ou-DTD-de-formats-XML-connus#comment-form</wfw:comment>
      <wfw:commentRss>http://batmat.net/blog/feed/rss2/comments/290</wfw:commentRss>
      </item>
    
  <item>
    <title>Toplink better than Hibernate?</title>
    <link>http://batmat.net/blog/post/2007/05/14/Toplink-better-than-Hibernate</link>
    <guid isPermaLink="false">urn:md5:2b0174536e271941bfaf28c6282bc090</guid>
    <pubDate>Mon, 14 May 2007 23:20:00 +0200</pubDate>
    <dc:creator>batmat</dc:creator>
        <category>Technique</category>
        <category>hibernate</category><category>oracle</category><category>toplink</category>    
    <description>    &lt;p&gt;Today, we received Oracle. They were coming to speak about their business Intelligence offer, Oracle Application Server and so on.&lt;/p&gt;


&lt;p&gt;When speaking about Toplink, the guy said something like: &quot;We could say Toplink is kind of a father to Hibernate. Obviously, it's already almost 15 years of existence.&quot; Well, why not. Though I didn't see any article interviewing Gavin King confirming that, but apart from reusing their ideas or not, Toplink was here before, OK.&lt;/p&gt;


&lt;p&gt;The assertion that surprised me was another one, something like:
&lt;q&gt;As Toplink is older than Hibernate, it's obviously more robust and has more functions.&lt;/q&gt;&lt;/p&gt;


&lt;p&gt;Well, I'm not sure I would agree with this one. In fact, as Toplink Essentials was only released in the OpenSource world very recently (may 2006 in Glassfish, so the JPA implementation even more, if I'm right), and experts seems to agree that about 90% of the projects today use Hibernate for the persistance layer (Didier Girard says it in the TV4IT Webcast. I think this is more of a feeling for him, so if anybody has some statistics about, I'm very interested. I should also ask Sami Jaber for his feeling about it.).&lt;/p&gt;


&lt;p&gt;Webcast (in french, see about 9/10 of the video for the &lt;q&gt;Hibernate is 90% of the current projects&lt;/q&gt;) :&lt;/p&gt;
&lt;embed	style=&quot;width:270px; height:224px;&quot; id=&quot;VideoPlayback&quot; type=&quot;application/x-shockwave-flash&quot; wmode=&quot;transparent&quot; src=&quot;http://storage02.brainsonic.com/webtv/tv4it/player.swf?&amp;paramXml=http://storage02.brainsonic.com/webtv/tv4it/param_player.xml&amp;itemId=2699&amp;autostart=false&amp;mute=false&amp;rollover=true&quot;&gt;&lt;/embed&gt;



&lt;p&gt;So, what is the right indicator about software robustness?&lt;/p&gt;


&lt;p&gt;Is this the software that's been released fifteen years ago, used by 10 people around the word since this time, or is this this other one, that's been released 6 years ago, used by 90 people since then? Who was the most testable? The one that only few people could download to give it a try, or the one that's been downloaded and tested tons of time by a lot different people?&lt;/p&gt;


&lt;p&gt;In my opinion, but I also agree I only know Hibernate, I'm pretty sure Hibernate has already been thoroughly tested. At least, as much as Toplink has. My point is that the maturing of Hibernate was a lot quicker than Toplink's one. Once more, it would be very interesting to put numbers in the debate. Hibernate has been opensourced since its start, so it always benefited from code reviews, patches and so on, and evolved very quickly.&lt;/p&gt;


&lt;p&gt;To sum up, because of the fundamental differences between both development styles, I'm not sure that today Hibernate is still behind Toplink speaking about robustness, functions scope and so on. Though I'd be delighted to learn about interesting differences, if you know about it.&lt;/p&gt;</description>
    
    
    
          <comments>http://batmat.net/blog/post/2007/05/14/Toplink-better-than-Hibernate#comment-form</comments>
      <wfw:comment>http://batmat.net/blog/post/2007/05/14/Toplink-better-than-Hibernate#comment-form</wfw:comment>
      <wfw:commentRss>http://batmat.net/blog/feed/rss2/comments/261</wfw:commentRss>
      </item>
    
  <item>
    <title>Différence entre Session.save() et Session.persist()</title>
    <link>http://batmat.net/blog/post/2007/01/02/238-difference-entre-sessionsave-et-sessionpersist</link>
    <guid isPermaLink="false">urn:md5:ac6456303af97f4ea17ef9c65df48125</guid>
    <pubDate>Tue, 02 Jan 2007 15:28:58 +0000</pubDate>
    <dc:creator>batmat</dc:creator>
        <category>Technique</category>
        <category>hibernate</category><category>java</category>    
    <description>    &lt;p&gt;Dans la version 3 d'Hibernate, d'un point de vue strictement utilitaire, il y a deux méthodes qui ont le même objectif&amp;nbsp;: sauvegarder un objet en base (ou le rendre persistant, comme on dit).&lt;/p&gt;


&lt;p&gt;Le problème est donc de savoir laquelle il faudrait plutôt utiliser. Et bien la réponse est simple, euuuu...&lt;/p&gt;


&lt;p&gt;Traduction de ce qu'on peut lire dans la &lt;a href=&quot;http://www.hibernate.org/116.html#A22&quot;&gt;FAQ&lt;/a&gt;&amp;nbsp;:&lt;/p&gt;


&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;Je ne sais pas si je dois utiliser save() ou persist().&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
Ces deux méthodes rendent persistante une instance éphémère (NdT&amp;nbsp;: transient). Toutefois, la méthode persist() ne garantit pas que la valeur de l'identifiant sera assignée immédiatement, l'assignement pourrait arriver au moment du flush.&lt;/p&gt;
&lt;p&gt;
La méthode persist() garantit aussi qu'aucun INSERT ne sera exécuté si elle est appelée en dehors d'un contexte transactionnel. Ceci est utile pour les conversations longues avec un contexte de persistance/session étendu.&lt;/p&gt;
&lt;p&gt;
La méthode save() ne garantit pas la même chose. Elle retourne un identifiant, et si un INSERT doit être exécuté pour obtenir l'identifiant it returns an identifier (e.g. générateur &quot;identity&quot;, pas &quot;sequence&quot;), cet INSERT arrive immédiatement, peu importe que vous soyez à l'intérieur ou à l'extérieur d'une transaction. Ce n'est pas bon pour les conversations longues avec un contexte de persistance/session étendu&lt;/p&gt;&lt;/blockquote&gt;


&lt;p&gt;En résumé, si vous faites des conversations longues, utilisez plutôt persist(). Sinon il y a peu de différence, mis à part toutefois le cascading. Celui-ci n'est propagé dans le cas de save() que si la relation est mappée &lt;em&gt;cascade=&quot;save-update&quot;&lt;/em&gt;, alors que c'est &lt;em&gt;cascade=&quot;persist&quot;&lt;/em&gt; pour persist().&lt;/p&gt;


&lt;p&gt;Notez que si vous mappez &lt;em&gt;cascade=&quot;all&quot;&lt;/em&gt;, cela inclue à la fois save-update et persist. Donc pour les relations mappées &quot;all&quot;, la sémantique de &lt;em&gt;persist()&lt;/em&gt; et de &lt;em&gt;save()&lt;/em&gt; sont à mon avis &lt;strong&gt;extrêmement proches&lt;/strong&gt;.&lt;/p&gt;</description>
    
    
    
          <comments>http://batmat.net/blog/post/2007/01/02/238-difference-entre-sessionsave-et-sessionpersist#comment-form</comments>
      <wfw:comment>http://batmat.net/blog/post/2007/01/02/238-difference-entre-sessionsave-et-sessionpersist#comment-form</wfw:comment>
      <wfw:commentRss>http://batmat.net/blog/feed/rss2/comments/231</wfw:commentRss>
      </item>
    
  <item>
    <title>Mapping Hibernate pour routeur...</title>
    <link>http://batmat.net/blog/post/2006/12/24/234-mapping-hibernate-pour-routeur</link>
    <guid isPermaLink="false">urn:md5:bb17d3f3492058eccd30cab1a7dbf213</guid>
    <pubDate>Sun, 24 Dec 2006 18:33:40 +0000</pubDate>
    <dc:creator>batmat</dc:creator>
        <category>Blogounette</category>
        <category>hibernate</category><category>humour</category>    
    <description>    &lt;p&gt;&lt;a href=&quot;http://forum.hibernate.org/viewtopic.php?p=2335173#2335173&quot;&gt;Extraordinaire&lt;/a&gt; :-).&lt;/p&gt;</description>
    
    
    
          <comments>http://batmat.net/blog/post/2006/12/24/234-mapping-hibernate-pour-routeur#comment-form</comments>
      <wfw:comment>http://batmat.net/blog/post/2006/12/24/234-mapping-hibernate-pour-routeur#comment-form</wfw:comment>
      <wfw:commentRss>http://batmat.net/blog/feed/rss2/comments/228</wfw:commentRss>
      </item>
    
  <item>
    <title>Java Persistence with Hibernate</title>
    <link>http://batmat.net/blog/post/2006/12/15/233-java-persistence-with-hibernate</link>
    <guid isPermaLink="false">urn:md5:26e034be00bc30d51f958ffc88c869a6</guid>
    <pubDate>Fri, 15 Dec 2006 23:19:27 +0000</pubDate>
    <dc:creator>batmat</dc:creator>
        <category>Général</category>
        <category>hibernate</category><category>java</category>    
    <description>    &lt;p&gt;Il y a quelques semaines, j'ai vu passer &lt;a href=&quot;http://blog.hibernate.org/cgi-bin/blosxom.cgi/2006/11/27#twentyfive&quot;&gt;ce billet&lt;/a&gt; sur le blog de l'équipe de développement d'&lt;a href=&quot;http://hibernate.org&quot;&gt;Hibernate&lt;/a&gt;. Étant donné que j'avais &quot;suffisamment&quot;, sans prétention aucune, contribué au forum d'Hibernate pour participer, j'ai immédiatement envoyé un mail à l'adresse indiquée. J'ai mis un descriptif très très court de mon expérience sur l'outil, tellement j'étais stressé d'avoir une chance de faire partie des heureux bénéficiaires et donc pressé d'avoir envoyé le mail :-).&lt;/p&gt;


&lt;p&gt;Je n'ai eu aucune nouvelle pendant environ une semaine, je ne savais absolument pas s'il y avait eu 25 personnes avant moi ou pas, puis j'ai reçu le 5 décembre ce mail de la part de &lt;a href=&quot;http://fr.wikipedia.org/wiki/Christian_Bauer&quot;&gt;Christian Bauer&lt;/a&gt;&amp;nbsp;:&lt;/p&gt;


&lt;blockquote&gt;&lt;p&gt;A copy of 'Java Persistence with Hibernate' is on its way to you.
Inside the US Manning expects to get the book to you this week, to
Europe and other countries it might take more than a week.&lt;/p&gt;
&lt;p&gt;
If there is any problem with the delivery please contact me directly.&lt;/p&gt;
&lt;p&gt;
Thank you again for contributing to Hibernate.&lt;/p&gt;&lt;/blockquote&gt;


&lt;p&gt;Et la &lt;a href=&quot;http://www.hibernate.org/401.html&quot;&gt;page récapitulative a été mise à jour&lt;/a&gt; :-).&lt;/p&gt;


&lt;p&gt;Bon, je me suis dit&amp;nbsp;: &lt;q&gt;Je n'en parle pas tant que ce n'est pas définitif&lt;/q&gt;. Pis finalement, je suis allé récupérer ça à la poste ce matin&amp;nbsp;:&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://batmat.net/dotclear/images/Hibernate/JPwH2.jpg&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;http://batmat.net/dotclear/images/Hibernate/JPwH1.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


&lt;p&gt;800 pages, il va me falloir un peu de temps avant d'éventuellement pouvoir reparler du contenu :-).&lt;/p&gt;</description>
    
    
    
          <comments>http://batmat.net/blog/post/2006/12/15/233-java-persistence-with-hibernate#comment-form</comments>
      <wfw:comment>http://batmat.net/blog/post/2006/12/15/233-java-persistence-with-hibernate#comment-form</wfw:comment>
      <wfw:commentRss>http://batmat.net/blog/feed/rss2/comments/226</wfw:commentRss>
      </item>
    
</channel>
</rss>
