<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8475025587762872101</id><updated>2026-04-06T16:23:15.861-07:00</updated><category term="spring"/><category term="spring-boot"/><category term="gradle"/><category term="java"/><category term="spring-boot-actuator"/><category term="amazon"/><category term="aws"/><category term="ec2"/><category term="evernote"/><category term="guava"/><category term="junit"/><category term="python"/><category term="testng"/><category term="thrift"/><title type='text'>Tadaya&#39;s Blog</title><subtitle type='html'>Software development is creative and must be fun!!</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default?start-index=26&amp;max-results=25'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-731313900065199866</id><published>2015-10-30T14:23:00.000-07:00</published><updated>2015-10-30T14:23:10.192-07:00</updated><title type='text'>THIS BLOG HAS MOVED</title><content type='html'>&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Please follow my new blog here: &lt;a href=&quot;http://ttddyy.github.io/&quot;&gt;http://ttddyy.github.io/&lt;/a&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/731313900065199866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/731313900065199866' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/731313900065199866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/731313900065199866'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2015/10/this-blog-has-moved.html' title='THIS BLOG HAS MOVED'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-1392975100235008579</id><published>2015-04-20T17:55:00.000-07:00</published><updated>2015-04-20T17:55:57.649-07:00</updated><title type='text'>released datasource-proxy v1.3</title><content type='html'>&lt;br /&gt;
I have released &lt;a href=&quot;https://github.com/ttddyy/datasource-proxy&quot;&gt;datasource-proxy version 1.3&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Changes:
&lt;ul&gt;
&lt;li&gt;new JNDI support&lt;/li&gt;
&lt;li&gt;JDBC4.2 (Java8) support&lt;/li&gt;
&lt;li&gt;fluent API builder for ProxyDataSource - “ProxyDataSourceBuilder”&lt;/li&gt;
&lt;li&gt;new Listeners for writing logs to System.out&lt;/li&gt;
&lt;li&gt;updated log format&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Please see more details in &lt;a href=&quot;https://github.com/ttddyy/datasource-proxy/blob/master/CHANGELOG.md&quot;&gt;CHANGELOG&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;Available in &lt;a href=&quot;http://search.maven.org/#artifactdetails|net.ttddyy|datasource-proxy|1.3|&quot;&gt;maven central&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
dependency:&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/ttddyy/79d11e16fb3e0be27a59.js&quot;&gt;&lt;/script&gt;

&amp;nbsp;project homepage: &lt;a href=&quot;https://github.com/ttddyy/datasource-proxy&quot;&gt;https://github.com/ttddyy/datasource-proxy&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/1392975100235008579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/1392975100235008579' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/1392975100235008579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/1392975100235008579'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2015/04/released-datasource-proxy-v13.html' title='released datasource-proxy v1.3'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-4510637720355614951</id><published>2014-01-06T10:18:00.000-08:00</published><updated>2014-01-06T10:18:58.528-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><category scheme="http://www.blogger.com/atom/ns#" term="spring-boot"/><title type='text'>Spring Boot: External Config File for Container Deployed War</title><content type='html'>&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
Spring Boot resolves external configuration file such as &lt;i&gt;&quot;application.properties&quot;&lt;/i&gt; or &lt;i&gt;&quot;application.yml&quot;&lt;/i&gt; in following order:&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;classpath root&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;current directory&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;classpath /config package&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;/config subdir of the current directory.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: right;&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;&lt;a href=&quot;http://projects.spring.io/spring-boot/docs/spring-boot/README.html&quot;&gt;[reference&amp;nbsp;spring-boot README]&lt;/a&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This is usually good for running spring boot application with executable jar (or war).&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: shell&quot;&gt;$ java -jar my-application.jar&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;However, when you convert your application to build a war file which gets deployed to a servlet container and want to keep the configuration file outside of the war file, the default search path doesn&#39;t work.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;One solution for this is that you can specify the external config file location in your servlet container&#39;s &lt;/span&gt;&lt;b style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;&quot;spring.config.location&quot; system property&lt;/i&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;For example, in tomcat:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;&quot;CATALINA_HOME/bin/setenv.sh&quot;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: shell&quot;&gt;export CATALINA_OPTS=&quot;-Dspring.config.location=file:/usr/local/myapp/application.properties&quot;&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;* The value of system property is evaluated as spring resource style format.&lt;br /&gt;So, if you are specifying a file outside of classpath, you need to put &lt;b&gt;&lt;i&gt;&quot;file:&quot;&lt;/i&gt;&lt;/b&gt; prefix.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;See more detail on&amp;nbsp;&lt;a href=&quot;https://github.com/spring-projects/spring-boot/blob/master/spring-boot/src/main/java/org/springframework/boot/context/initializer/ConfigFileApplicationContextInitializer.java&quot;&gt;org.springframework.boot.context.initializer.ConfigFileApplicationContextInitializer&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/4510637720355614951/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/4510637720355614951' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/4510637720355614951'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/4510637720355614951'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2014/01/spring-boot-external-config-file-for.html' title='Spring Boot: External Config File for Container Deployed War'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-7647731281170234441</id><published>2013-12-01T22:12:00.000-08:00</published><updated>2013-12-01T22:12:50.511-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="evernote"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="thrift"/><title type='text'>Library to make null-safe collections in thrift generated java object. </title><content type='html'>&lt;br /&gt;
&lt;div&gt;
&lt;div&gt;
While I was experimenting &lt;a href=&quot;http://dev.evernote.com/doc/&quot;&gt;evernote java API&lt;/a&gt;, I found thrift generated code for container types(list,set,map) are not really java friendly, especially for for-loop.&lt;br /&gt;
In thrift, when value is set to null, the transport will not send the field. But in java, when collection is null, the enhanced-for-loop throws NullPointerException.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;Note note = noteStore.getNote(...);
// This throws NPE when the note doesn&#39;t have any resources
for (Resource resource : note.getResources()) {
...
}
&lt;/pre&gt;
&lt;br /&gt;
I can put if-statement to check the collection whenever I need to access it, but that&#39;s just repetitive...&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
So, I wrote a util class that wraps thrift generated class to make it null-safe.&lt;br /&gt;
&lt;br /&gt;
* w() is a static method in ThriftWrapper class which I wrote.&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;Note wrapped = w(new Note());  // wrapped
for (Resource resource : wrapped.getResources()) {
  // no more NPE. nested thrift attributes are also null-safe
}
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h3&gt;
Mechanism:&lt;/h3&gt;
&lt;div&gt;
The wrapping method introspect the given thrift object and set empty mutable collections(ArrayList, HashSet, HashMap) when it finds null in collection fields. Also, it traverse child thrift classes and set empty collections as well.(foo.getBar().getBaz().getList()).&lt;/div&gt;
&lt;div&gt;
Then it returns cglib generated proxy. Since in thrift, null has a meaning when it serializes object, the proxy keeps track of collection fields which were initially null, and when &quot;write()&quot; method is called, it compares the current value and if it&#39;s still empty, then it will omit the field to transport.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
wrapping behavior:&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;Note note = new Note();
note.setAttributes(new NoteAttributes());
assertThat(note.getTagGuids(), is(nullValue()));
assertThat(note.getAttributes().getClassifications(), is(nullValue()));

Note wrapped = w(note);
assertThat(wrapped.getTagGuids(), is(emptyCollectionOf(String.class)));
assertThat(wrapped.getAttributes().getClassifications(), is(notNullValue()));
assertThat(wrapped.getAttributes().getClassifications().size(), is(0));
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
transport behavior:&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;Note note = new Note();
Note wrapped = w(note);  // still a note instance  (actually a cglib proxy)
wrapped.getTagGuids().size();  // 0 (empty list)
wrapped.getResources().add(...);  // add something to collection

noteStore.createNote(wrapped);  // internally call wrapped.write(...)
// added resources are included in message, but tag-guids are not

&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Please reference more detailed behavior in &lt;a href=&quot;https://github.com/ttddyy/nullsafe-thrift/tree/master/src/test/java/net/ttddyy/nullsafethrift&quot;&gt;test classes&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
Code:&lt;/h3&gt;
&lt;div&gt;
I pushed to &lt;a href=&quot;https://github.com/ttddyy/nullsafe-thrift&quot;&gt;my github repo&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
Further:&lt;/h3&gt;
&lt;div&gt;
Since I&#39;m new to thrift, it might not be a good approach or there might be a better solution already.&lt;/div&gt;
&lt;div&gt;
If there is more request for this approach, I&#39;ll further enhance the project such:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;inline cglib to avoid dependency conflict&lt;/li&gt;
&lt;li&gt;make the class more spring-framework friendly bean instead of static methods&lt;/li&gt;
&lt;li&gt;release and push to public maven repo&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/7647731281170234441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/7647731281170234441' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/7647731281170234441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/7647731281170234441'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2013/12/library-to-make-null-safe-collections.html' title='Library to make null-safe collections in thrift generated java object. '/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-6085198565536423014</id><published>2013-10-30T22:26:00.000-07:00</published><updated>2013-10-30T22:26:02.891-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><category scheme="http://www.blogger.com/atom/ns#" term="spring-boot"/><category scheme="http://www.blogger.com/atom/ns#" term="spring-boot-actuator"/><title type='text'>Spring Boot Actuator: How to change the endpoint base url</title><content type='html'>&lt;br /&gt;
By default, actuator management endpoints are mapped to the top level url: &quot;/info&quot;, &quot;/metrics&quot;, &quot;/beans&quot;, etc.&lt;br /&gt;
&lt;div&gt;
&lt;div&gt;
That may be good. But probably it would be better to have some base path. For example, &quot;/admin/metrics&quot; or &quot;/manage/info&quot;.&lt;br /&gt;
Spring Boot provides quick and easy solution.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h4&gt;
Configuration&lt;/h4&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
In your configuration resource file (application.properties or application.yml):&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: text&quot;&gt;management.contextPath: /admin
&lt;/pre&gt;
&lt;div&gt;
&lt;div&gt;
Now, all the management endpoints are mapped under &quot;/admin&quot; base path.&lt;/div&gt;
&lt;div&gt;
&quot;/admin/metrics&quot;, &quot;/admin/info&quot;, &quot;/admin/health&quot;...&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;h4&gt;
Implementation Classes&lt;/h4&gt;
&lt;div&gt;
In spring boot actuator source code:&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;org.springframework.boot.actuate.properties.ManagementServerProperties&lt;/i&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;property values representation class&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;i&gt;org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration&lt;/i&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;@Configuration which uses above ManagementServerProperties&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/6085198565536423014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/6085198565536423014' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/6085198565536423014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/6085198565536423014'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2013/10/spring-boot-actuator-how-to-change.html' title='Spring Boot Actuator: How to change the endpoint base url'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-6906875895325476630</id><published>2013-10-18T15:43:00.000-07:00</published><updated>2013-10-20T20:31:33.642-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="spring-boot"/><category scheme="http://www.blogger.com/atom/ns#" term="spring-boot-actuator"/><title type='text'>How spring-boot enables actuator by adding jar dependency?</title><content type='html'>&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;I was reading &lt;a href=&quot;https://github.com/spring-projects/spring-boot&quot;&gt;spring-boot source code&lt;/a&gt;, and wondered how it is auto-detecting actuator features just by adding jar dependency.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
spring-boot-actuator&lt;/span&gt;&lt;/h2&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;
&quot;spring-boot-actuator&quot; adds management-endpoints(http) to the spring-boot application just by adding the jar file.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;endpoints are metrics, health-check, spring-security auth audit, etc.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;
please see &lt;a href=&quot;https://github.com/spring-projects/spring-boot/blob/master/spring-boot-actuator/docs/Features.md&quot;&gt;here&lt;/a&gt; for feature details.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;
To add actuator to your spring-boot application, add this dependencies:&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&lt;dependency&gt;
    &lt;groupid&gt;org.springframework.boot&lt;/groupid&gt;
    &lt;artifactid&gt;spring-boot-starter-actuator&lt;/artifactid&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupid&gt;org.springframework.boot&lt;/groupid&gt;
    &lt;artifactid&gt;spring-boot-starter-web&lt;/artifactid&gt;
&lt;/dependency&gt;
&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h2&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
Mechanism of auto-detecting spring-boot-actuator&lt;/span&gt;&lt;/h2&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;So, how spring-boot application detects spring-boot-actuator?&lt;/span&gt;&lt;br /&gt;
&lt;h4&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Sample spring-boot application:&lt;/span&gt;&lt;/h4&gt;
&lt;pre class=&quot;brush: java&quot;&gt;@Configuration
@EnableAutoConfiguration
@ComponentScan
public class MyApplication {

    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}&lt;/pre&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;i&gt;&quot;org.springframework.boot.SpringApplication&quot;&lt;/i&gt; is the starting point for spring-boot application.&lt;/span&gt;&lt;br /&gt;
&lt;h4&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Auto-detection Steps&lt;/span&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;During &lt;i&gt;&quot;SpringApplication#run&quot;&lt;/i&gt; method, it creates an application context from the given source classes(&quot;@Configuration&quot; annotated classes). In this case &quot;MyApplication&quot; class.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;When &quot;MyApplication&quot; class is being processed as a spring&#39;s Java-configuration, &quot;@EnableAutoConfiguration&quot; annotation gets interpreted. &quot;@EnableAutoConfiguration&quot; is a spring-boot(autoconfigure) annotation which is handled by &lt;i&gt;&quot;org.springframework.boot.autoconfigure.EnableAutoConfigurationImportSelector&quot;&lt;/i&gt;. (how spring handles @Enable* annotation is well documented in this blog &lt;a href=&quot;http://blog.fawnanddoug.com/2012/08/how-those-spring-enable-annotations-work.html&quot;&gt;post&lt;/a&gt;.)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;In &quot;EnableAutoConfigurationImportSelector&quot;, it uses &lt;i&gt;&quot;org.springframework.core.io.support.SpringFactoriesLoader#loadFactoryNames&quot;&lt;/i&gt;&amp;nbsp;from spring-core to load configurations whose key is &amp;nbsp;&lt;i&gt;&quot;org.springframework.boot.autoconfigure.EnableAutoConfiguration&quot;&lt;/i&gt;.&lt;br /&gt;This method reads &quot;META-INF/spring.factories&quot; from jar files.(multiple jar files can have &quot;spring.factories&quot; and when they have same key, comma delimited values will be merged.)&lt;br /&gt;spring-boot-actuator contains &quot;META-INF/spring.factories&quot; file. The value of the file is a comma delimited list of &quot;@Configuration&quot; classes under&amp;nbsp;&lt;i&gt;&quot;org.springframework.boot.actuate.autoconfigure&quot;&lt;/i&gt; package, which are actuator bean definition classes.&lt;/span&gt;
&lt;pre class=&quot;brush: java&quot; title=&quot;spring.factories in spring-boot-actuator&quot;&gt;org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.boot.actuate.autoconfigure.AuditAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.ErrorMvcAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.ManagementServerPropertiesAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.MetricFilterAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.MetricRepositoryAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.SecurityAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.TraceRepositoryAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.TraceWebFilterAutoConfiguration&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;These&amp;nbsp;configuration classes will be imported into the main application-context, so that,&amp;nbsp;spring-boot-actuator beans become available in the application.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;div style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
Same mechanism is used for&amp;nbsp;&lt;i&gt;&quot;spring-boot-autoconfigure&quot;&lt;/i&gt;.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
Its jar file contains &quot;spring.factories&quot; file.&lt;/div&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;h3&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Writing a Custom Spring-Boot Module&lt;/span&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;In sum, you can write a spring-boot module which will be auto-detected by spring-boot application based on the presence of the jar file:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;li&gt;include &lt;i&gt;&quot;META-INF/spring.factories&quot;&lt;/i&gt; file&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;key: &quot;org.springframework.boot.autoconfigure.EnableAutoConfiguration&quot;&lt;/li&gt;
&lt;li&gt;value: comma delimited path to @Configuration file(s) for your module&lt;/li&gt;
&lt;/ul&gt;
&lt;/span&gt;&lt;/ul&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/6906875895325476630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/6906875895325476630' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/6906875895325476630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/6906875895325476630'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2013/10/how-spring-boot-enables-actuator-by.html' title='How spring-boot enables actuator by adding jar dependency?'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-3961843075894524675</id><published>2013-10-10T11:20:00.000-07:00</published><updated>2013-10-10T11:20:01.331-07:00</updated><title type='text'>released datasource-proxy v1.2</title><content type='html'>&lt;br /&gt;
I released &lt;a href=&quot;https://github.com/ttddyy/datasource-proxy&quot;&gt;datasource-proxy version 1.2&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
main feature:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;query and parameter replacement&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;new QueryTransformer and ParameterTransformer APIs to transform query and parameter before executing queries&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;many refactoring&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
They are available in &lt;a href=&quot;http://search.maven.org/#search%7Cga%7C1%7Cdatasource-proxy&quot;&gt;maven central&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
dependency:&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/ttddyy/6922873.js&quot;&gt;&lt;/script&gt;

&amp;nbsp;project homepage: &lt;a href=&quot;https://github.com/ttddyy/datasource-proxy&quot;&gt;https://github.com/ttddyy/datasource-proxy&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/3961843075894524675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/3961843075894524675' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/3961843075894524675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/3961843075894524675'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2013/10/released-datasource-proxy-v12.html' title='released datasource-proxy v1.2'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-7623690421594465346</id><published>2012-12-11T23:02:00.000-08:00</published><updated>2012-12-16T19:29:24.076-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="amazon"/><category scheme="http://www.blogger.com/atom/ns#" term="aws"/><category scheme="http://www.blogger.com/atom/ns#" term="ec2"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>display ec2-name and ip-address as ssh-config or hosts file</title><content type='html'>&lt;div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; color: black; font-family: Arial; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;br /&gt;
Inspired by this &lt;a href=&quot;http://instagram-engineering.tumblr.com/post/11399488246/simplifying-ec2-ssh-connections&quot;&gt;instagram engineering blog&lt;/a&gt;, I wrote a python script to printout ec2 hostname and ip-address as ssh-config or hosts file format.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; color: black; font-family: Arial; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
In our environment, unfortunately we don&#39;t have dns for ec2 hosts, for now.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; color: black; font-family: Arial; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
I use /etc/hosts. Some people use ssh-config file.&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; color: black; font-family: Arial; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;br /&gt;
This script may help others who are in similar environment where using ssh-config or hosts file to manage ec2-host mapping.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Usage&lt;/h3&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/f15a7b5148dc73dd8dd8.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h3&gt;
ec2-printconfig script &lt;/h3&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/4264117.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/7623690421594465346/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/7623690421594465346' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/7623690421594465346'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/7623690421594465346'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2012/12/display-ec2-name-and-ip-address-as-ssh.html' title='display ec2-name and ip-address as ssh-config or hosts file'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-6936601575182718956</id><published>2012-06-14T23:44:00.000-07:00</published><updated>2012-06-15T09:28:43.938-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="guava"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="junit"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><category scheme="http://www.blogger.com/atom/ns#" term="testng"/><title type='text'>util method that runs TestNG test classes and verify the result</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
I wrote &lt;a href=&quot;https://github.com/ttddyy/test-contexts/blob/master/test-contexts-core/src/test/java/net/ttddyy/testcontexts/TestNGUtils.java&quot;&gt;a utility class&lt;/a&gt; for &lt;a href=&quot;https://github.com/ttddyy/test-contexts&quot;&gt;my project&lt;/a&gt;.&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;
The method does:&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;run TestNG tests programmatically&lt;/li&gt;
&lt;li&gt;verify the failures happened in TestNG tests run&lt;/li&gt;
&lt;li&gt;If there is a failure, combine all assertion messages including stack trace, then make a single AssertionError&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
(I&#39;m also using google-guava)&lt;/div&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/2928025.js&quot;&gt;
 
&lt;/script&gt;

&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/6936601575182718956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/6936601575182718956' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/6936601575182718956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/6936601575182718956'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2012/06/util-method-that-runs-testng-test.html' title='util method that runs TestNG test classes and verify the result'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-6750176706724495574</id><published>2012-03-25T15:43:00.000-07:00</published><updated>2012-03-25T15:43:04.589-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gradle"/><title type='text'>run jetty on dependency resolved war in gradle</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
Background:&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;test classes(such as selenium tests) are in an independent module(maven project, etc.).&lt;/li&gt;
&lt;li&gt;have an external dependency(mave, ivy, etc) to war file(s)&lt;/li&gt;
&lt;li&gt;want to run jetty on dependent war file(s)&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;p1&quot;&gt;
Gradle can start up jetty on dependency resolved war file(s).&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/2197625.js&quot;&gt;
 
&lt;/script&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
When you want to run your tests after jetty started, set &quot;daemon=true&quot; and make the test task depends on your new run-war task.&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/6750176706724495574/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/6750176706724495574' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/6750176706724495574'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/6750176706724495574'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2012/03/run-jetty-on-dependency-resolved-war-in.html' title='run jetty on dependency resolved war in gradle'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-192867618474456346</id><published>2012-03-05T22:07:00.000-08:00</published><updated>2012-03-25T12:20:55.733-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gradle"/><title type='text'>run multiple jetty in gradle</title><content type='html'>&lt;br /&gt;
Background:&lt;br /&gt;
I have a selenium test suite for end-to-end web testing.&lt;br /&gt;
Currently, it is running on jenkins box but it is taking so long to finish all the tests.&lt;br /&gt;
So, next step is to parallelize the selenium tests.&lt;br /&gt;
As a first step, I need to start multiple jetty servers using different port.&lt;br /&gt;
&lt;br /&gt;
With Gradle jetty plugin, I camp up how to run the multiple jetty servers before tests.&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/1968643.js&quot;&gt;
 
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/192867618474456346/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/192867618474456346' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/192867618474456346'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/192867618474456346'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2012/03/run-multiple-jetty-in-gradle.html' title='run multiple jetty in gradle'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-3020994836464266802</id><published>2011-06-30T13:05:00.000-07:00</published><updated>2011-06-30T13:48:50.802-07:00</updated><title type='text'>run same command on multiple directories</title><content type='html'>&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;I&#39;ve been working on applications that consist of multiple maven projects.&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Many time, I have to type same commands on multiple project directories, such as &quot;mvn install&quot;, &quot;svn up&quot;, &quot;git …&quot;, etc.&lt;/div&gt;&lt;div class=&quot;p2&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 14px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p2&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 14px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;I wrote a bash script that executes given command(s) on multiple directories.&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Multiple Directory Command&lt;/b&gt;:&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3206ee;&quot;&gt;&lt;span class=&quot;s1&quot; style=&quot;text-decoration: underline;&quot;&gt;&lt;a href=&quot;https://github.com/ttddyy/utils/tree/master/multi_command&quot;&gt;https://github.com/ttddyy/utils/tree/master/multi_command&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 14px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p2&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 14px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p2&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 14px;&quot;&gt;Sample: &lt;i&gt;(mc is the script alias I use)&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 14px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;gt; mc svn up &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# svn up all projects&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;gt; mc -g projA mvn install &amp;nbsp; &amp;nbsp; # call &quot;mvn install&quot; on porjA group directories(defined in config file)&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;gt; mc git checkout -b new_branch master &amp;nbsp;# create a new git branch to all project&lt;/div&gt;&lt;div class=&quot;p2&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 14px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;gt; mc git branch &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# display current git branch in all project&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;gt; mc -g projA svn up &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # &amp;nbsp;&quot;svn up&quot; projA directories&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;gt; mc -g projB -c config_file du -sh &amp;nbsp;# chcek directory size of projB directories&lt;/div&gt;&lt;div class=&quot;p2&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 14px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;p1&quot; style=&quot;font: normal normal normal 12px/normal Arial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;please see more options&amp;nbsp;&lt;a href=&quot;https://github.com/ttddyy/utils/tree/master/multi_command&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/3020994836464266802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/3020994836464266802' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/3020994836464266802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/3020994836464266802'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2011/06/run-same-command-on-multiple.html' title='run same command on multiple directories'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-5861935794114937726</id><published>2010-01-28T21:41:00.000-08:00</published><updated>2010-01-28T21:51:16.452-08:00</updated><title type='text'>datasource-proxy framework</title><content type='html'>--&lt;br /&gt;
I&#39;m writing a framework that helps monitoring and debugging query execution from app.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://code.google.com/p/datasource-proxy/&quot;&gt;[Project Home] &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Features:&lt;br /&gt;
- log all database queries with parameter values&lt;br /&gt;
- log each query&#39;s elapsed time&lt;br /&gt;
- log statistics of all database call and total query elapsed time&lt;br /&gt;
- provide callback to database call&lt;br /&gt;
- provide statistics object &lt;br /&gt;
&lt;br /&gt;
Database Call Log:&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;Time:10, Num:1, Query:{[insert into emp ( id, name )values (?, ?);][1, foo]}
Time:1, Num:1, Query:{[select this_.id as id0_0_, this_.name as name0_0_, this_.value as value0_0_ from emp this_ where (this_.id=? and this_.name=?)][1,bar]}
&lt;/pre&gt;&lt;br /&gt;
Statistics Log:&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;DataSource:MyDatasourceA ElapsedTime:13 Call:7 Query:7 (Select:3 Insert:2 Update:1 Delete:0 Other:1)
DataSource:MyDatasourceB ElapsedTime:1 Call:1 Query:1 (Select:1 Insert:0 Update:0 Delete:0 Other:0)
&lt;/pre&gt;&lt;br /&gt;
If you are interested,&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;project homepage &lt;a href=&quot;http://code.google.com/p/datasource-proxy/&quot;&gt;http://code.google.com/p/datasource-proxy/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;download &lt;a href=&quot;http://code.google.com/p/datasource-proxy/downloads/list&quot;&gt;http://code.google.com/p/datasource-proxy/downloads/list&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;ul&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/5861935794114937726/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/5861935794114937726' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/5861935794114937726'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/5861935794114937726'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2010/01/datasource-proxy-framework.html' title='datasource-proxy framework'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-5289289574071241179</id><published>2007-09-03T12:36:00.001-07:00</published><updated>2011-09-12T22:00:44.185-07:00</updated><title type='text'>Hibernate: Association Mappings in Annotation (JPA style)</title><content type='html'>Unidirectional Association&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/02/hibernate-annotation-many-to-oneforeign.html&quot;&gt; many to one &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(8.2.1)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-m21&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/03/hibernate-annotation-one-to-oneforeign.html&quot;&gt; one to one (foreign key) &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(8.2.2)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-121&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/03/hibernate-annotation-one-to-one-primary.html&quot;&gt; one to one (primary key) &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(8.2.2)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-121&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-many.html&quot;&gt; one to many (foreign key) &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(8.2.3)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-12m&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Unidirectional Association with Join Table&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-many-join.html&quot;&gt; one to many &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;8.3.1&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-join-12m&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-annotation-many-to-one-join.html&quot;&gt; many to one &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;8.3.2&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-join-m21&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-one-join.html&quot;&gt; one to one &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;8.3.3&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-join-121&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-annotation-many-to-many-join.html&quot;&gt; many to many &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;8.3.4&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-join-m2m&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Bidirectional Association&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-annotation-many-to-many.html&quot;&gt; one to many / many to one &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;8.4.1&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-bidirectional-m21&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-one-foreign.html&quot;&gt; one to one (foreign key) &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;8.4.2&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-bidirectional-121&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-one-primary.html&quot;&gt; one to one (primary key) &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;8.4.2&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-bidirectional-121&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Bidirectional Association with Join Table&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-manymany-to.html&quot;&gt; one to many / many to one &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;8.5.1&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-bidirectional-join-12m&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-manymany-to_03.html&quot;&gt; one to one &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;8.5.2&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-bidirectional-join-121&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-annotation-many-to-many-join_03.html&quot;&gt; many to many &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;8.5.3&lt;/span&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;    &lt;/span&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-bidirectional-join-m2m&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;&lt;span style=&quot;color: black; font-size: 85%;&quot;&gt;[ref]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: right;&quot;&gt;
&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;(*) hibernate document chapter&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;Reference:&lt;br /&gt;
- &lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/index.html&quot;&gt;hibernate documentation&lt;/a&gt;&lt;br /&gt;
- &lt;a href=&quot;http://java.sun.com/products/ejb/docs.html&quot;&gt;EJB 3.0 Spec&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/5289289574071241179/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/5289289574071241179' title='16 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/5289289574071241179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/5289289574071241179'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html' title='Hibernate: Association Mappings in Annotation (JPA style)'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>16</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-4793504951949937502</id><published>2007-09-03T11:17:00.000-07:00</published><updated>2011-09-12T21:51:53.018-07:00</updated><title type='text'>Hibernate: Annotation many-to-many (join table)</title><content type='html'>Bidirectonal many-to-many (join table) association&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-bidirectional-join-m2m&quot;&gt;Hibernate Doc (Chap 8.5.3)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Relationship::&lt;br /&gt;
person(many) &amp;lt;-&amp;gt; address(many)&lt;br /&gt;
&lt;br /&gt;
::DB Schema::&lt;br /&gt;
person(&lt;u&gt;personId&lt;/u&gt;)&lt;br /&gt;
address(&lt;u&gt;addressId&lt;/u&gt;)&lt;br /&gt;
personaddress(personId, addressId)&lt;br /&gt;
&lt;br /&gt;
::Java Operation::&lt;br /&gt;
person.getAddresses();&lt;br /&gt;
address.getPeople();&lt;br /&gt;
&lt;br /&gt;
::Annotation::&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;PERSON&quot;)
public class Person {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;personId&quot;)
  private int id;

  // mapping owner
  @ManyToMany
  @JoinTable(name = &quot;PersonAddress&quot;,
    joinColumns = {
      @JoinColumn(name=&quot;personId&quot;, unique = true)           
    },
    inverseJoinColumns = {
      @JoinColumn(name=&quot;addressId&quot;)
    }
  )
  private Set&amp;lt;Address&amp;gt; addresses;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;ADDRESS&quot;)
public class Address {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;addressId&quot;)
  private int id;

  @ManyToMany(mappedBy=&quot;addresses&quot;)  // map info is in person class
  private Set&amp;lt;Person&amp;gt; people;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Generated SQL::&lt;br /&gt;
- person.getAddresses();&lt;br /&gt;
select addresses0_.personId as personId1_, addresses0_.addressId as addressId1_, address1_.addressId as addressId3_0_ from PersonAddress addresses0_ left outer join ADDRESS address1_ on addresses0_.addressId=address1_.addressId where addresses0_.personId=?&lt;br /&gt;
&lt;br /&gt;
- address.getPeople();&lt;br /&gt;
select people0_.addressId as addressId1_, people0_.personId as personId1_, person1_.personId as personId2_0_ from PersonAddress people0_ left outer join PERSON person1_ on people0_.personId=person1_.personId where people0_.addressId=?&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html&quot;&gt;[Association Mapping List]&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/4793504951949937502/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/4793504951949937502' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/4793504951949937502'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/4793504951949937502'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2007/09/hibernate-annotation-many-to-many-join_03.html' title='Hibernate: Annotation many-to-many (join table)'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-7879570078701522164</id><published>2007-09-03T11:16:00.000-07:00</published><updated>2011-09-12T21:52:59.218-07:00</updated><title type='text'>Hibernate: Annotation one-to-one (join table)</title><content type='html'>Bidirectonal one-to-one (join table) association (very unusual)&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-bidirectional-join-121&quot;&gt;Hibernate Doc (Chap 8.5.2)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Relationship::&lt;br /&gt;
person(one)(mapping owner) &amp;lt;-&amp;gt; address(one)&lt;br /&gt;
&lt;br /&gt;
::DB Schema::&lt;br /&gt;
person(&lt;u&gt;personId&lt;/u&gt;)&lt;br /&gt;
address(&lt;u&gt;addressId&lt;/u&gt;)&lt;br /&gt;
personaddress(personId, addressId)&lt;br /&gt;
&lt;br /&gt;
::Java Operation::&lt;br /&gt;
person.getAddress();&lt;br /&gt;
address.getPerson();&lt;br /&gt;
&lt;br /&gt;
::Annotation::&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;


@Entity
@Table(name = &quot;PERSON&quot;)
public class Person {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;personId&quot;)
  private int id;

  @OneToOne(optional=true)
  @JoinTable(name=&quot;PersonAddress&quot;,
    joinColumns = {
      @JoinColumn(name=&quot;personId&quot;, unique = true)           
    },
    inverseJoinColumns = {
      @JoinColumn(name=&quot;addressId&quot;)
    }     
  )
  private Address address;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;ADDRESS&quot;)
public class Address {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;addressId&quot;)
  private int id;

  @OneToOne(optional=true, mappedBy=&quot;address&quot;) // pointing to Person&#39;s address field
  private Person person;   
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Generated SQL::&lt;br /&gt;
- person.getAddress();&lt;br /&gt;
select person0_.personId as personId2_2_, person0_1_.addressId as addressId3_2_, address1_.addressId as addressId4_0_, address1_1_.personId as personId3_0_, person2_.personId as personId2_1_, person2_1_.addressId as addressId3_1_ from PERSON person0_ left outer join PersonAddress person0_1_ on person0_.personId=person0_1_.personId left outer join ADDRESS address1_ on person0_1_.addressId=address1_.addressId left outer join PersonAddress address1_1_ on address1_.addressId=address1_1_.addressId left outer join PERSON person2_ on address1_1_.personId=person2_.personId left outer join PersonAddress person2_1_ on person2_.personId=person2_1_.personId where person0_.personId=?&lt;br /&gt;
&lt;br /&gt;
- address.getPerson();&lt;br /&gt;
select address0_.addressId as addressId4_2_, address0_1_.personId as personId3_2_, person1_.personId as personId2_0_, person1_1_.addressId as addressId3_0_, address2_.addressId as addressId4_1_, address2_1_.personId as personId3_1_ from ADDRESS address0_ left outer join PersonAddress address0_1_ on address0_.addressId=address0_1_.addressId inner join PERSON person1_ on address0_1_.personId=person1_.personId left outer join PersonAddress person1_1_ on person1_.personId=person1_1_.personId left outer join ADDRESS address2_ on person1_1_.addressId=address2_.addressId left outer join PersonAddress address2_1_ on address2_.addressId=address2_1_.addressId where address0_.addressId=?&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html&quot;&gt;[Association Mapping List]&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/7879570078701522164/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/7879570078701522164' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/7879570078701522164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/7879570078701522164'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-manymany-to_03.html' title='Hibernate: Annotation one-to-one (join table)'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-8819532129420128159</id><published>2007-09-03T11:15:00.000-07:00</published><updated>2011-09-12T21:53:34.015-07:00</updated><title type='text'>Hibernate: Annotation one-to-many/many-to-one (join table)</title><content type='html'>Bidirectonal one-to-many/many-to-one (join table) association&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-bidirectional-join-12m&quot;&gt;Hibernate Doc (Chap 8.5.1)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Relationship::&lt;br /&gt;
person(one) &amp;lt;-&amp;gt; address(one)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::DB Schema::&lt;br /&gt;
person(&lt;u&gt;personId&lt;/u&gt;)&lt;br /&gt;
personAddress(personId, addressId)&lt;br /&gt;
address(&lt;u&gt;addressId&lt;/u&gt;)&lt;br /&gt;
&lt;br /&gt;
::Java Operation::&lt;br /&gt;
person.getAddress();&lt;br /&gt;
address.getPerson();&lt;br /&gt;
&lt;br /&gt;
::Annotation::&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;PERSON&quot;)
public class Person {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;personId&quot;)
  private int id;

  @OneToMany
  @JoinTable(name = &quot;PersonAddress&quot;,
    joinColumns = {
      @JoinColumn(name=&quot;personId&quot;, unique = true)           
    },
    inverseJoinColumns = {
      @JoinColumn(name=&quot;addressId&quot;)
    }
  )
  private Set&amp;lt;Address&amp;gt; addresses;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;ADDRESS&quot;)
public class Address {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;addressId&quot;)
  private int id;

  @ManyToOne(optional=true)
  @JoinTable(name = &quot;PersonAddress&quot;,
    joinColumns = {
      @JoinColumn(name=&quot;addressId&quot;)
    },
    inverseJoinColumns = {
      @JoinColumn(name=&quot;personId&quot;)
    }
  )
  private Person person;   
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Generated SQL::&lt;br /&gt;
- person.getAddresses();&lt;br /&gt;
select addresses0_.personId as personId2_, addresses0_.addressId as addressId2_, address1_.addressId as addressId3_0_, address1_1_.personId as personId4_0_, person2_.personId as personId2_1_ from PersonAddress addresses0_ left outer join ADDRESS address1_ on addresses0_.addressId=address1_.addressId left outer join PersonAddress address1_1_ on address1_.addressId=address1_1_.addressId left outer join PERSON person2_ on address1_1_.personId=person2_.personId where addresses0_.personId=?&lt;br /&gt;
&lt;br /&gt;
- address.getPerson();&lt;br /&gt;
select address0_.addressId as addressId3_1_, address0_1_.personId as personId4_1_, person1_.personId as personId2_0_ from ADDRESS address0_ left outer join PersonAddress address0_1_ on address0_.addressId=address0_1_.addressId left outer join PERSON person1_ on address0_1_.personId=person1_.personId where address0_.addressId=?&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html&quot;&gt;[Association Mapping List]&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/8819532129420128159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/8819532129420128159' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/8819532129420128159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/8819532129420128159'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-manymany-to.html' title='Hibernate: Annotation one-to-many/many-to-one (join table)'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-7598608595166022923</id><published>2007-09-03T11:14:00.000-07:00</published><updated>2011-09-12T21:53:58.172-07:00</updated><title type='text'>Hibernate: Annotation one-to-one (primary-key)</title><content type='html'>Bidirectonal one-to-one (primary-key) association&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-bidirectional-121&quot;&gt;Hibernate Doc (Chap 8.4.2)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Relationship::&lt;br /&gt;
person(one) &amp;lt;-&amp;gt; address(one)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::DB Schema::&lt;br /&gt;
person(&lt;u&gt;personId&lt;/u&gt;)&lt;br /&gt;
address(&lt;u&gt;personId&lt;/u&gt;) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Java Operation::&lt;br /&gt;
person.getAddress();&lt;br /&gt;
address.getPerson();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Annotation::&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name=&quot;PERSON&quot;)
public class Person {
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name=&quot;personId&quot;)
  private int id;
 
  @OneToOne
  @PrimaryKeyJoinColumn
  private Address address;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;ADDRESS&quot;)
public class Address {

  @Id
  @Column(name = &quot;personId&quot;)
  private int id;

  @OneToOne(mappedBy=&quot;address&quot;)  // inverse=true, pointnig Person&#39;s address field
  private Person person;   
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Generated SQL::&lt;br /&gt;
- person.getAddress();&lt;br /&gt;
select person0_.personId as personId2_2_, address1_.personId as personId3_0_, person2_.personId as personId2_1_ from PERSON person0_ left outer join ADDRESS address1_ on person0_.personId=address1_.personId left outer join PERSON person2_ on address1_.personId=person2_.personId where person0_.personId=?&lt;br /&gt;
&lt;br /&gt;
- address.getPerson();&lt;br /&gt;
select address0_.personId as personId3_2_, person1_.personId as personId2_0_, address2_.personId as personId3_1_ from ADDRESS address0_ left outer join PERSON person1_ on address0_.personId=person1_.personId left outer join ADDRESS address2_ on person1_.personId=address2_.personId where address0_.personId=?&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html&quot;&gt;[Association Mapping List]&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/7598608595166022923/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/7598608595166022923' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/7598608595166022923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/7598608595166022923'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-one-primary.html' title='Hibernate: Annotation one-to-one (primary-key)'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-1876864081921848497</id><published>2007-09-03T11:12:00.000-07:00</published><updated>2011-09-12T21:54:20.198-07:00</updated><title type='text'>Hibernate: Annotation one-to-one (foreign-key)</title><content type='html'>Bidirectonal one-to-one (foreign-key) association&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-bidirectional-121&quot;&gt;Hibernate Doc (Chap 8.4.2)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Relationship::&lt;br /&gt;
person(one) &amp;lt;-&amp;gt; address(one)&lt;br /&gt;
&lt;br /&gt;
::DB Schema::&lt;br /&gt;
person(&lt;u&gt;id&lt;/u&gt;, addressId)&lt;br /&gt;
address(&lt;u&gt;id&lt;/u&gt;)&lt;br /&gt;
&lt;br /&gt;
::Java Operation::&lt;br /&gt;
person.getAddress();&lt;br /&gt;
address.getPerson();&lt;br /&gt;
&lt;br /&gt;
::Annotation::&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name=&quot;PERSON&quot;)
public class Person {
   
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name=&quot;personId&quot;)
  private int id;
 
  @ManyToOne
  @JoinColumn(name=&quot;addressId&quot;)     // inverse = false
  private Address address;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;ADDRESS&quot;)
public class Address {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;addressId&quot;)
  private int id;

  @OneToOne(mappedBy=&quot;address&quot;)  // inverse=true, pointnig Person&#39;s address field
  private Person person;   
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Generated SQL::&lt;br /&gt;
- person.getAddress();&lt;br /&gt;
select person0_.personId as personId2_1_, person0_.addressId as addressId2_1_, address1_.addressId as addressId3_0_ from PERSON person0_ left outer join ADDRESS address1_ on person0_.addressId=address1_.addressId where person0_.personId=?&lt;br /&gt;
&lt;br /&gt;
- address.getPerson();&lt;br /&gt;
select person0_.personId as personId2_1_, person0_.addressId as addressId2_1_, address1_.addressId as addressId3_0_ from PERSON person0_ left outer join ADDRESS address1_ on person0_.addressId=address1_.addressId where person0_.addressId=?&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html&quot;&gt;[Association Mapping List]&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/1876864081921848497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/1876864081921848497' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/1876864081921848497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/1876864081921848497'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-one-foreign.html' title='Hibernate: Annotation one-to-one (foreign-key)'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-444742855720181841</id><published>2007-09-03T11:10:00.000-07:00</published><updated>2011-09-12T21:55:08.210-07:00</updated><title type='text'>Hibernate: Annotation one-to-many/many-to-one</title><content type='html'>Bidirectonal one-to-many/many-to-one association&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-bidirectional-m21&quot;&gt;Hibernate Doc (Chap 8.4.1)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
::Relationship::&lt;br /&gt;
person(many) &amp;lt;-&amp;gt; address(one)&lt;br /&gt;
- person A and person B live in address AA&lt;br /&gt;
&lt;br /&gt;
::DB Schema::&lt;br /&gt;
person(&lt;u&gt;personId&lt;/u&gt;, addressId)&lt;br /&gt;
address(&lt;u&gt;addressId&lt;/u&gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Java Operation::&lt;br /&gt;
person.getAddress();&lt;br /&gt;
address.getPeople();&lt;br /&gt;
&lt;br /&gt;
::Annotation::&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name=&quot;PERSON&quot;)
public class Person {
   
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name=&quot;personId&quot;)
  private int id;
   
  @ManyToOne
  @JoinColumn(name=&quot;addressId&quot;)     // inverse = false
  private Address address;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;ADDRESS&quot;)
public class Address {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;addressId&quot;)
  private int id;

  @OneToMany(mappedBy=&quot;address&quot;)  // pointing Person&#39;s address field
  @Column(name=&quot;personId&quot;)    // inverse=true
  private Set&amp;lt;Person&amp;gt; people;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Generated SQL::&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html&quot;&gt;[Association Mapping List]&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/444742855720181841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/444742855720181841' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/444742855720181841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/444742855720181841'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2007/09/hibernate-annotation-many-to-many.html' title='Hibernate: Annotation one-to-many/many-to-one'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-8182868399159657636</id><published>2007-09-03T11:08:00.000-07:00</published><updated>2011-09-12T21:55:29.889-07:00</updated><title type='text'>Hibernate: Annotation many-to-many (join table)</title><content type='html'>Unidirectonal many-to-many (join table)) association&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-join-m2m&quot;&gt;Hibernate Doc (Chap 8.3.4)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Relationship::&lt;br /&gt;
person(many) -&amp;gt; address(many)&lt;br /&gt;
&lt;br /&gt;
::DB Schema::&lt;br /&gt;
person(&lt;u&gt;personId&lt;/u&gt;)&lt;br /&gt;
address(&lt;u&gt;addressId&lt;/u&gt;)&lt;br /&gt;
personaddress(personId, addressId)&lt;br /&gt;
&lt;br /&gt;
::Java Operation::&lt;br /&gt;
person.getAddresses();&lt;br /&gt;
&lt;br /&gt;
::Annotation::&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;PERSON&quot;)
public class Person {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;personId&quot;)
  private int id;

  @ManyToMany
  @JoinTable(name = &quot;PersonAddress&quot;,
    joinColumns = {
      @JoinColumn(name=&quot;personId&quot;, unique = true)           
    },
    inverseJoinColumns = {
      @JoinColumn(name=&quot;addressId&quot;)
    }
  )
  private Set&amp;lt;Address&amp;gt; addresses;
}  &lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;ADDRESS&quot;)
public class Address {
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;addressId&quot;)
  private int id;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Generated SQL::&lt;br /&gt;
- person.getAddresses();&lt;br /&gt;
&lt;br /&gt;
select addresses0_.personId as personId1_, addresses0_.addressId as addressId1_, address1_.addressId as addressId3_0_ from PersonAddress addresses0_ left outer join ADDRESS address1_ on addresses0_.addressId=address1_.addressId where addresses0_.personId=?&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html&quot;&gt;[Association Mapping List]&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/8182868399159657636/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/8182868399159657636' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/8182868399159657636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/8182868399159657636'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2007/09/hibernate-annotation-many-to-many-join.html' title='Hibernate: Annotation many-to-many (join table)'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-712009059165823117</id><published>2007-09-03T11:06:00.000-07:00</published><updated>2011-09-12T21:56:14.400-07:00</updated><title type='text'>Hibernate: Annotation one-to-one (join table)</title><content type='html'>Unidirectonal one-to-one (join table) association&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-join-121&quot;&gt;Hibernate Doc (Chap 8.3.3)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
::Relationship::&lt;br /&gt;
person(one) -&amp;gt; address(one)&lt;br /&gt;
&lt;br /&gt;
::DB Schema::&lt;br /&gt;
person(&lt;u&gt;personId&lt;/u&gt;)&lt;br /&gt;
address(&lt;u&gt;addressId&lt;/u&gt;)&lt;br /&gt;
personaddress(personId, addressId)&lt;br /&gt;
&lt;br /&gt;
::Java Operation::&lt;br /&gt;
person.getAddress();&lt;br /&gt;
&lt;br /&gt;
::Annotation::&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;PERSON&quot;)
@Entity
@Table(name = &quot;PERSON&quot;)
public class Person {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;personId&quot;)
  private int id;

  @OneToOne(optional=true)
  @JoinTable(name=&quot;PersonAddress&quot;,
    joinColumns = {
      @JoinColumn(name=&quot;personId&quot;, unique = true)           
    },
    inverseJoinColumns = {
      @JoinColumn(name=&quot;addressId&quot;)
    }     
  )
  private Address address;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;ADDRESS&quot;)
public class Address {
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;addressId&quot;)
  private int id;  
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Generated SQL::&lt;br /&gt;
- person.getAddress();&lt;br /&gt;
&lt;br /&gt;
select person0_.personId as personId2_1_, person0_1_.addressId as addressId3_1_, address1_.addressId as addressId4_0_ from PERSON person0_ left outer join PersonAddress person0_1_ on person0_.personId=person0_1_.personId left outer join ADDRESS address1_ on person0_1_.addressId=address1_.addressId where person0_.personId=?&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html&quot;&gt;[Association Mapping List]&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/712009059165823117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/712009059165823117' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/712009059165823117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/712009059165823117'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-one-join.html' title='Hibernate: Annotation one-to-one (join table)'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-3796019125987304774</id><published>2007-09-03T11:04:00.000-07:00</published><updated>2011-09-12T21:56:30.313-07:00</updated><title type='text'>Hibernate: Annotation many-to-one (join table)</title><content type='html'>&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-join-m21&quot;&gt;Hibernate Doc (Chap 8.3.2)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Relationship::&lt;br /&gt;
person(many) -&amp;gt; address(one)&lt;br /&gt;
&lt;br /&gt;
ex) person A and person B live in address AA&lt;br /&gt;
&lt;br /&gt;
::DB Schema::&lt;br /&gt;
person (&lt;u&gt;personId&lt;/u&gt;)&lt;br /&gt;
addres (&lt;u&gt;addressId&lt;/u&gt;)&lt;br /&gt;
personAddress (personId, addressId)&lt;br /&gt;
&lt;br /&gt;
::Java Operation::&lt;br /&gt;
person.getAddress();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Annotation::&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;PERSON&quot;)
public class Person {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;personId&quot;)
  private int id;

  @ManyToOne(optional=true)
  @JoinTable(name=&quot;PersonAddress&quot;,
    joinColumns = {
      @JoinColumn(name=&quot;personId&quot;, unique = true)           
    },
    inverseJoinColumns = {
      @JoinColumn(name=&quot;addressId&quot;)
    }     
  )
  private Address address;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;ADDRESS&quot;)
public class Address {
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;addressId&quot;)
  private int id;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Generated SQL::&lt;br /&gt;
- person.getAddress();&lt;br /&gt;
&lt;br /&gt;
select person0_.personId as personId2_1_,&lt;br /&gt;
person0_1_.addressId as addressId3_1_,&lt;br /&gt;
address1_.addressId as addressId4_0_&lt;br /&gt;
from PERSON person0_ left outer join PersonAddress person0_1_ on person0_.personId=person0_1_.personId&lt;br /&gt;
left outer join ADDRESS address1_ on person0_1_.addressId=address1_.addressId&lt;br /&gt;
where person0_.personId=?&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html&quot;&gt;[Association Mapping List]&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/3796019125987304774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/3796019125987304774' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/3796019125987304774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/3796019125987304774'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2007/09/hibernate-annotation-many-to-one-join.html' title='Hibernate: Annotation many-to-one (join table)'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-5718438085642535463</id><published>2007-09-03T11:02:00.000-07:00</published><updated>2011-09-12T21:57:35.324-07:00</updated><title type='text'>Hibernate: Annotation one-to-many( join table)</title><content type='html'>Unidirectonal one-to-many (join table) association&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-join-12m&quot;&gt;Hibernate Doc (Chap 8.3.1)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Relationship::&lt;br /&gt;
person(one) -&amp;gt; address(many)&lt;br /&gt;
&lt;br /&gt;
::Java Operation::&lt;br /&gt;
person.getAddresses();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Annotation::&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;

@Entity
@Table(name = &quot;PERSON&quot;)
public class Person {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;personId&quot;)
  private int id;

  @OneToMany
  @JoinTable(name = &quot;PersonAddress&quot;,
    joinColumns = {
      @JoinColumn(name=&quot;personId&quot;, unique = true)           
    },
    inverseJoinColumns = {
      @JoinColumn(name=&quot;addressId&quot;)
    }
  )
  private Set&amp;lt;Address&amp;gt; addresses;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;
@Entity
@Table(name = &quot;ADDRESS&quot;)
public class Address {
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = &quot;addressId&quot;)
  private int id;
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::Generated SQL::&lt;br /&gt;
- person.getAddresses();&lt;br /&gt;
select addresses0_.personId as personId1_, addresses0_.addressId as addressId1_, address1_.addressId as addressId3_0_ from PersonAddress addresses0_ left outer join ADDRESS address1_ on addresses0_.addressId=address1_.addressId where addresses0_.personId=?&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html&quot;&gt;[Association Mapping List]&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/5718438085642535463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/5718438085642535463' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/5718438085642535463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/5718438085642535463'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-many-join.html' title='Hibernate: Annotation one-to-many( join table)'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8475025587762872101.post-1647757003730520244</id><published>2007-09-03T10:55:00.000-07:00</published><updated>2011-08-03T23:10:08.975-07:00</updated><title type='text'>Hibernate: Annotation one-to-many (foreign-key)</title><content type='html'>&lt;a href=&quot;http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional-12m&quot;&gt;Hibernate Doc (Chap 8.2.3)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
::Relationship::&lt;br /&gt;
person(one) -&amp;gt; address(many)&lt;br /&gt;
&lt;br /&gt;
::DB Schema::&lt;br /&gt;
person( &lt;u&gt;personId&lt;/u&gt; )&lt;br /&gt;
address( &lt;u&gt;addressId&lt;/u&gt;, personId )&lt;br /&gt;
&lt;br /&gt;
::Java Operation::&lt;br /&gt;
person.getAddresses();&lt;br /&gt;
&lt;br /&gt;
::Annotation::&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;@Entity
@Table(name=&quot;PERSON&quot;)
public class Person {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name=&quot;personId&quot;)
private int id;

@OneToMany
@JoinColumn(name=&quot;personId&quot;) 
private Set &amp;lt;Address&amp;gt; addresses;
}
&lt;/pre&gt;&lt;br /&gt;
&lt;pre class=&quot;box&quot;&gt;@Entity
@Table(name = &quot;ADDRESS&quot;)
public class Address {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = &quot;addressId&quot;)
private int id;
}
&lt;/pre&gt;&lt;br /&gt;
::Generated SQL (mysql5.0)::&lt;br /&gt;
&lt;a href=&quot;http://tadtech.blogspot.com/2007/09/hibernate-association-mappings-in.html&quot;&gt;[Association Mapping List]&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://tadtech.blogspot.com/feeds/1647757003730520244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8475025587762872101/1647757003730520244' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/1647757003730520244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8475025587762872101/posts/default/1647757003730520244'/><link rel='alternate' type='text/html' href='http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-many.html' title='Hibernate: Annotation one-to-many (foreign-key)'/><author><name>ttddyy</name><uri>http://www.blogger.com/profile/13171169321033441226</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbJCsts6HlA73dshjOm0rQG5GlX5BCsnEOz0ig64dO5VHVWYzUeT_BzJcG5GaHDgBG8tBK0LtIu409w79dfCr9f9K7H_VmRG9WQh0Xt3gyPLDpliwJtE8l3uA72q6_rl8/s220/4e0291d3ec92da082b62dfdfc2145524.png'/></author><thr:total>7</thr:total></entry></feed>