<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CUIDRHozfCp7ImA9WhRaFE8.&quot;"><id>tag:blogger.com,1999:blog-702546477551195221</id><updated>2012-02-16T12:19:35.484-08:00</updated><category term="java ee" /><category term="eclipse" /><category term="references" /><category term="java 1.6" /><category term="tips" /><category term="database" /><category term="entity beans" /><title>tuesdayDeveloper;</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://tuesdaydeveloper.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://tuesdaydeveloper.blogspot.com/" /><author><name>Mahon</name><uri>http://www.blogger.com/profile/03453966321305664305</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="21" height="32" src="http://bp3.blogger.com/_1Pd7xJqxpjA/R9lQ2br37hI/AAAAAAAAAJI/J0aR0uuEN2s/S220/me-over-fire.JPG" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/Tuesdaydeveloper" /><feedburner:info uri="tuesdaydeveloper" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;C08CR3o6cSp7ImA9WxBTFUQ.&quot;"><id>tag:blogger.com,1999:blog-702546477551195221.post-2001230495383567441</id><published>2009-12-11T20:23:00.000-08:00</published><updated>2009-12-11T20:24:26.419-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-11T20:24:26.419-08:00</app:edited><title>New Home</title><content type="html">Hey everyone, &lt;br /&gt;&lt;br /&gt;tuesdayDeveloper has found a new home. If you are reading this you will probably be forwarded shortly, if not click &lt;a href="http://tuesdayDeveloper.com/"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/702546477551195221-2001230495383567441?l=tuesdaydeveloper.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/QfSi7W2WfMeAYhgSXfK_pPKvJ2Y/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QfSi7W2WfMeAYhgSXfK_pPKvJ2Y/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/QfSi7W2WfMeAYhgSXfK_pPKvJ2Y/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QfSi7W2WfMeAYhgSXfK_pPKvJ2Y/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Tuesdaydeveloper/~4/4ny4FyThrcU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://tuesdaydeveloper.blogspot.com/feeds/2001230495383567441/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://tuesdaydeveloper.blogspot.com/2009/12/new-home.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/2001230495383567441?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/2001230495383567441?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Tuesdaydeveloper/~3/4ny4FyThrcU/new-home.html" title="New Home" /><author><name>Mahon</name><uri>http://www.blogger.com/profile/03453966321305664305</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="21" height="32" src="http://bp3.blogger.com/_1Pd7xJqxpjA/R9lQ2br37hI/AAAAAAAAAJI/J0aR0uuEN2s/S220/me-over-fire.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://tuesdaydeveloper.blogspot.com/2009/12/new-home.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUENRXc-fCp7ImA9WxBTE0U.&quot;"><id>tag:blogger.com,1999:blog-702546477551195221.post-5213127501479968423</id><published>2009-12-09T10:29:00.001-08:00</published><updated>2009-12-09T10:34:54.954-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-09T10:34:54.954-08:00</app:edited><title>Lazy vs. Eager in Java EE</title><content type="html">So you have a relational database and you want to see what &lt;code&gt;Addresse&lt;/code&gt;s, &lt;code&gt;Phone&lt;/code&gt; numbers, or &lt;code&gt;Account&lt;/code&gt;s are associated with a &lt;code&gt;Person&lt;/code&gt;. By default, Java EE will only get the objects it absolutely needs; this is called lazy fetching. So solve this problem you want to fetch eagerly. In your code, find the attribute in your entity bean that you want to eagerly fetch and edit the attributes to indicate that it should eagerly fetch the information:&lt;div&gt;In the &lt;code&gt;Person&lt;/code&gt; bean:&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;@OneToMany(mappedBy="person", fetch=FetchType.EAGER)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;private Set&lt;account&gt; accounts;&lt;/code&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/702546477551195221-5213127501479968423?l=tuesdaydeveloper.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/U3O6YcoLdlGcJzNEP0U--hWNTcc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/U3O6YcoLdlGcJzNEP0U--hWNTcc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/U3O6YcoLdlGcJzNEP0U--hWNTcc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/U3O6YcoLdlGcJzNEP0U--hWNTcc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Tuesdaydeveloper/~4/E_0gaAoCt1k" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://tuesdaydeveloper.blogspot.com/feeds/5213127501479968423/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://tuesdaydeveloper.blogspot.com/2009/12/lazy-vs-eager-in-java-ee.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/5213127501479968423?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/5213127501479968423?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Tuesdaydeveloper/~3/E_0gaAoCt1k/lazy-vs-eager-in-java-ee.html" title="Lazy vs. Eager in Java EE" /><author><name>Mahon</name><uri>http://www.blogger.com/profile/03453966321305664305</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="21" height="32" src="http://bp3.blogger.com/_1Pd7xJqxpjA/R9lQ2br37hI/AAAAAAAAAJI/J0aR0uuEN2s/S220/me-over-fire.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://tuesdaydeveloper.blogspot.com/2009/12/lazy-vs-eager-in-java-ee.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQGRH8_eCp7ImA9WxBTE0U.&quot;"><id>tag:blogger.com,1999:blog-702546477551195221.post-2159924025919238198</id><published>2009-12-09T10:25:00.000-08:00</published><updated>2009-12-09T10:28:45.140-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-09T10:28:45.140-08:00</app:edited><title>Query Without Primary Key in Java EE</title><content type="html">It is extremely simple to get an entity bean object from a database based on the primary key:&lt;div&gt;&lt;code&gt;    public Person getPerson(String personId) {&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Person aPerson = manager.find(Person.class, personId);&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;return aPerson;&lt;/div&gt;&lt;div&gt;    }&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But what if you don't have the primary key, like when you want to log in and you only have the userid and the password?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For this you will need to actually write a query, but do not fear, it is very simple:&lt;/div&gt;&lt;div&gt;&lt;code&gt;    public Person getPerson(String userid, String password) {&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;if(userid == null || password == null) {&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;return null;&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;try {&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Query q = manager.createQuery("select p from Person p where p.userid = :uid and p.password = :pass");&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;q.setParameter("uid", userid);&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;q.setParameter("pass", password);&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Person aPerson = (Person) q.getSingleResult();&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;if(aPerson == null) {&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;return null;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;return aPerson;&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;catch (Exception e) {&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;return null;&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;/code&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/702546477551195221-2159924025919238198?l=tuesdaydeveloper.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-Kk69xQHJo2EFaG3IdJIz3XPmps/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-Kk69xQHJo2EFaG3IdJIz3XPmps/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-Kk69xQHJo2EFaG3IdJIz3XPmps/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-Kk69xQHJo2EFaG3IdJIz3XPmps/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Tuesdaydeveloper/~4/C_rdYURwiYk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://tuesdaydeveloper.blogspot.com/feeds/2159924025919238198/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://tuesdaydeveloper.blogspot.com/2009/12/query-without-primary-key-in-java-ee.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/2159924025919238198?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/2159924025919238198?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Tuesdaydeveloper/~3/C_rdYURwiYk/query-without-primary-key-in-java-ee.html" title="Query Without Primary Key in Java EE" /><author><name>Mahon</name><uri>http://www.blogger.com/profile/03453966321305664305</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="21" height="32" src="http://bp3.blogger.com/_1Pd7xJqxpjA/R9lQ2br37hI/AAAAAAAAAJI/J0aR0uuEN2s/S220/me-over-fire.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://tuesdaydeveloper.blogspot.com/2009/12/query-without-primary-key-in-java-ee.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUYHRXw7fip7ImA9WxBTE0U.&quot;"><id>tag:blogger.com,1999:blog-702546477551195221.post-1119293803112401987</id><published>2009-12-08T18:31:00.000-08:00</published><updated>2009-12-09T10:25:34.206-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-09T10:25:34.206-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="references" /><category scheme="http://www.blogger.com/atom/ns#" term="java ee" /><category scheme="http://www.blogger.com/atom/ns#" term="java 1.6" /><title>Comparing Two Collections</title><content type="html">This is a valuable piece of code that I am sure I'll be using in the future:&lt;div&gt;&lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;code&gt;&lt;div&gt;&lt;div&gt;    public boolean isSame(Collection expected, Collection actual) {&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt; &lt;/span&gt;/* first compair the sizes, if they are not the same there is no use in going further */&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;if(expected.size() != actual.size()) {&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;return false;&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt; &lt;/span&gt;/* the count variable will increment for each match */&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;int count = 0;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt; &lt;/span&gt;/* The iterators check each object in each Collection */&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;for (Iterator iterator = expected.iterator(); iterator.hasNext();) {&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;Object object = (Object) iterator.next();&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;for (Iterator iterator2 = actual.iterator(); iterator2.hasNext();) {&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;Object object2 = (Object) iterator2.next();&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;if(object2.equals(object)) {&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;     &lt;/span&gt;count++;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt; &lt;/span&gt;/* the count variable is the same as the size of the Collections then all items match */&lt;/div&gt;&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;if (count != expected.size()) {&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;return false;&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;else {&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;return true;&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;I wrote it to check if and expected &lt;code&gt;Set&lt;/code&gt; was the same as an actual &lt;code&gt;Set&lt;/code&gt;. I chose to use a &lt;code&gt;Collection&lt;/code&gt; to make it more generic, and since a &lt;code&gt;Set&lt;/code&gt;  is a &lt;code&gt;Collection&lt;/code&gt; it will still work.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/702546477551195221-1119293803112401987?l=tuesdaydeveloper.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/wxshjHteb-PXzg9HKAtGd0nyNok/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wxshjHteb-PXzg9HKAtGd0nyNok/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/wxshjHteb-PXzg9HKAtGd0nyNok/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wxshjHteb-PXzg9HKAtGd0nyNok/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Tuesdaydeveloper/~4/KWma_loZxHs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://tuesdaydeveloper.blogspot.com/feeds/1119293803112401987/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://tuesdaydeveloper.blogspot.com/2009/12/comparing-two-collections.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/1119293803112401987?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/1119293803112401987?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Tuesdaydeveloper/~3/KWma_loZxHs/comparing-two-collections.html" title="Comparing Two Collections" /><author><name>Mahon</name><uri>http://www.blogger.com/profile/03453966321305664305</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="21" height="32" src="http://bp3.blogger.com/_1Pd7xJqxpjA/R9lQ2br37hI/AAAAAAAAAJI/J0aR0uuEN2s/S220/me-over-fire.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://tuesdaydeveloper.blogspot.com/2009/12/comparing-two-collections.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkQCSXw8cCp7ImA9WxBTE08.&quot;"><id>tag:blogger.com,1999:blog-702546477551195221.post-10051053661378195</id><published>2009-12-07T17:45:00.000-08:00</published><updated>2009-12-08T19:12:48.278-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-08T19:12:48.278-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="java ee" /><category scheme="http://www.blogger.com/atom/ns#" term="java 1.6" /><category scheme="http://www.blogger.com/atom/ns#" term="entity beans" /><category scheme="http://www.blogger.com/atom/ns#" term="database" /><title>Connecting Entity Beans to Set/Retrieve Data</title><content type="html">&lt;div&gt;I've spent the last week figuring this out, ultimately I had one line that was wrong.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;When you have the database set up, and the &lt;a href="http://tuesdaydeveloper.blogspot.com/2009/11/connecting-entity-beans-to-server.html"&gt;entity beans in an EJB project&lt;/a&gt;, how do you connect to the server to access or update data?&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Prerequisites: You should have &lt;a href="http://tuesdaydeveloper.blogspot.com/2009/11/connecting-entity-beans-to-server.html"&gt;entity beans in an EJB Project that reference a database&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;You should have two classes set up in your EJB project: BusinessRules.java, BusinessRulesRemote.java (or whatever you chose to call them). These files have a special method to construction, follow the list below.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Secondary click the EJB project and select New &gt; Session Bean&lt;/li&gt;&lt;li&gt;Enter the package and class name (I chose "session" and  "BusinessRules")&lt;/li&gt;&lt;li&gt;If you want to use a remote interface (best for scalability) you will need to select it. You may leave the local interface (best for performance) button checked or you may uncheck it, I unchecked it.&lt;/li&gt;&lt;li&gt;Click finish.&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;li&gt;Edit your BusinessRules.java and BusinessRulesRemote.java class.&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Now you need to implement your business logic.&lt;br /&gt;&lt;code style="margin-left='10px'"&gt;@Stateless /*These business rules are stateless.*/&lt;br /&gt;public class BusinessRules implements BusinessRulesRemote { /*class header*/&lt;br /&gt;@PersistenceContext /*If you are using Java EE then you will need this to get the Persistent context*/&lt;br /&gt;EntityManager manager; /*The manager you'll be using*/&lt;br /&gt;public static final String REMOTEJNDINAME = BusinessRules.class.getSimpleName() + "/remote"; /*JNDI name so that the class can be found*/&lt;br /&gt;&lt;br /&gt;public BusinessRules() { //Default constructor&lt;br /&gt;}&lt;/code&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;Note: if you use &lt;code&gt;@PersistenceUnit&lt;/code&gt; instead of &lt;code&gt;@PersitenceContext&lt;/code&gt; it will not work.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You will need to have methods in the &lt;code&gt;BusinessRules&lt;/code&gt; class in order to access your data. Here is an example of how to select a person using their primary key (continued from the code above):&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;/code&gt;&lt;/div&gt;&lt;code&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt;public Person getPerson(String personId) {&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt;Person aPerson = manager.find(Person.class, personId);&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt;return aPerson;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/code&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; After you do this you will just need to call an instance of your &lt;code&gt;BusinessRules&lt;/code&gt; class (&lt;code&gt;businessRules&lt;/code&gt;) and then call methods (e.g. &lt;code&gt;businessRuless.getPerson("1");)&lt;/code&gt;&lt;/div&gt; In order to get an Object &lt;code&gt;Person&lt;/code&gt; as an entity from your database based on their username and password you will want to overload your method in &lt;code&gt;BusinessRules&lt;/code&gt; (or just not use the former method since it isn't very practical) and write a query using EJB QL. Example (continued from code above):&lt;/div&gt;&lt;div&gt;&lt;code&gt;    public Person getPerson(String userid, String password) {&lt;/code&gt;&lt;/div&gt;&lt;code&gt;&lt;/code&gt;&lt;div&gt;&lt;code&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Query q = manager.createQuery("select p from Person p where p.userid = :uid and p.password = :pass");&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;q.setParameter("uid", userid);&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;q.setParameter("pass", password);&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Person aPerson = (Person) q.getSingleResult();&lt;/div&gt;&lt;div&gt;    &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;return aPerson;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;/code&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Resources: &lt;a href="http://java.sun.com/javaee/6/docs/tutorial/doc/giqpj.html"&gt;Sun&lt;/a&gt;, Enterprise JavaBeans 3.0 5th Edition 2006 Bill Burke &amp;amp; Richard Monson-Haefel&lt;/div&gt;&lt;/div&gt;&lt;code&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/702546477551195221-10051053661378195?l=tuesdaydeveloper.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/KlDGxjbSR3UlmBsUeaSu7un_i14/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KlDGxjbSR3UlmBsUeaSu7un_i14/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/KlDGxjbSR3UlmBsUeaSu7un_i14/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KlDGxjbSR3UlmBsUeaSu7un_i14/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Tuesdaydeveloper/~4/5iIkKhHWvCY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://tuesdaydeveloper.blogspot.com/feeds/10051053661378195/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://tuesdaydeveloper.blogspot.com/2009/12/connecting-entity-beans-to-setretrieve.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/10051053661378195?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/10051053661378195?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Tuesdaydeveloper/~3/5iIkKhHWvCY/connecting-entity-beans-to-setretrieve.html" title="Connecting Entity Beans to Set/Retrieve Data" /><author><name>Mahon</name><uri>http://www.blogger.com/profile/03453966321305664305</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="21" height="32" src="http://bp3.blogger.com/_1Pd7xJqxpjA/R9lQ2br37hI/AAAAAAAAAJI/J0aR0uuEN2s/S220/me-over-fire.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://tuesdaydeveloper.blogspot.com/2009/12/connecting-entity-beans-to-setretrieve.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUEGQ3Y-cSp7ImA9WxNaE0g.&quot;"><id>tag:blogger.com,1999:blog-702546477551195221.post-8432465878511855853</id><published>2009-11-21T09:00:00.000-08:00</published><updated>2009-11-27T13:33:42.859-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-27T13:33:42.859-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="references" /><category scheme="http://www.blogger.com/atom/ns#" term="java ee" /><category scheme="http://www.blogger.com/atom/ns#" term="entity beans" /><category scheme="http://www.blogger.com/atom/ns#" term="database" /><title>Reference: Data Isolation and Database Locking</title><content type="html">&lt;div&gt;&lt;div&gt;There are several problems that can occur on a relational database when muliple users are accessing the same data.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;b&gt;Dirty Read:&lt;/b&gt; (No, it's not a romance novel.) When a record is changed by "Person A" but hasn't yet been committed. "Person B" reads the data that hasn't been updated. It can also occur when "Person B" reads data that ins't committed to the database, if "Person A's" transaction is rolled back, the data that Person B has read is no longer valid.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;b&gt;Example:&lt;/b&gt; (numbers are indicative of time intervals) Two people share a bank account, "A" wants to pay a bill which requires the called method to debit and then credit their account record in the database.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;1- "A" reads that there is $300 in his bank account.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;2- "A" starts to pay a bill and his account is debited by $150&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;3- "B" looks at the account balance and reads that there is $150&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;4- An error occurs when "A's" transaction is processing the credit to the payees table and the transaction is rolled back. The account balance is now $300 again.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;This is an example of a dirty read because the information that "B" has is no longer valid.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;br /&gt;&lt;b&gt;Non-repeatable Read:&lt;/b&gt; Is the same as a dirty read but it involves a second record call from the database, if the second time the same record different, it is a non-repeatable read. (Up until the data is changed, it is still a dirty read.)&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;b&gt;Example:&lt;/b&gt; "A" and "B" share an account. "A" wants to pay a bill which requires the called method to debit and then credit their account record in the database.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;1- "A" reads the account balance, $300&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;2- "B" reads the account balance, $300&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;3- "A" debits the account balance, it is now $150&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;4- "B" reads the account balance again and the value has changed&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;br /&gt;&lt;b&gt;Phantom Read:&lt;/b&gt; When a record is deleted or a new record is added to a database that effects what another user is doing.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;b&gt;Example:&lt;/b&gt; "A" is a client for an online store, "B" is the manager for the store.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;1- "A" reads that there is 3 widgets in inventory.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;2- "B" receives a shipment and updates the inventory of the widgets to 5003&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;3- "A" hurries to by before there are none left, but when he is done there is over 5000 widgets in the store.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;These problems call for transaction isolation. Transaction isolation restricts how users can access data in the database. There are four different levels for Java EJBs:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;b&gt;Read Uncommitted:&lt;/b&gt; This is the lowest level of isolation, it allows dirty reads, non-repeatable reads, and phantom reads. This level of isolation can be used when you are not worried about collisions in the data and you're willing to sort them out if any.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;b&gt;Read Committed:&lt;/b&gt; A transaction cannot read uncommitted data, a record (or a table depending on your DBMS) will be locked and that data cannot be read by other transactions. This prevents dirty reads, but allows both non-repeatable reads and phantom reads.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;b&gt;Repeatable Read:&lt;/b&gt; This level of isolation prevents one transaction from changing data that is being read by another transaction. This prevents both dirty reads and non-repeatable reads, but phantom reads can still occur.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;b&gt;Serializable: &lt;/b&gt;Only one transaction has read and write privileges at a time. This prevents all read/write problems, but may cause performance to be slow for its users.&lt;/div&gt;&lt;div style="margin-left: 25px; "&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Just like anything else, there is give an take with what is ideal and what can occur in an application that interacts with a database. In general I think that users are understanding that other users can have an effect on the data, but it is still something you should plan for. Perhaps if one user is viewing data that another user is updating it would be appropriate to indicate that there is something going on there so that the users understand why their transaction is taking so long, or at least to let them guess that their data may have changed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Resources: Enterprise JavaBeans 3.0 5th Edition 2006 Bill Burke &amp;amp; Richard Monson-Haefel&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/702546477551195221-8432465878511855853?l=tuesdaydeveloper.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Zz5adoqyq-Fw_HiJJp5fI3k70A0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Zz5adoqyq-Fw_HiJJp5fI3k70A0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Zz5adoqyq-Fw_HiJJp5fI3k70A0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Zz5adoqyq-Fw_HiJJp5fI3k70A0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Tuesdaydeveloper/~4/jkgi5nCoG_Y" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://tuesdaydeveloper.blogspot.com/feeds/8432465878511855853/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://tuesdaydeveloper.blogspot.com/2009/11/reference-data-isolation-and-database.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/8432465878511855853?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/8432465878511855853?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Tuesdaydeveloper/~3/jkgi5nCoG_Y/reference-data-isolation-and-database.html" title="Reference: Data Isolation and Database Locking" /><author><name>Mahon</name><uri>http://www.blogger.com/profile/03453966321305664305</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="21" height="32" src="http://bp3.blogger.com/_1Pd7xJqxpjA/R9lQ2br37hI/AAAAAAAAAJI/J0aR0uuEN2s/S220/me-over-fire.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://tuesdaydeveloper.blogspot.com/2009/11/reference-data-isolation-and-database.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEIMSH4-fSp7ImA9WxNbFk0.&quot;"><id>tag:blogger.com,1999:blog-702546477551195221.post-2251173910286648075</id><published>2009-11-16T19:23:00.000-08:00</published><updated>2009-11-18T20:56:29.055-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-18T20:56:29.055-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="tips" /><title>Eclipse Hint: Clean Your Projects</title><content type="html">Earlier today when I was working on a project I took a look at one of my entity beans and it had all sorts of errors in it. Seeing as how I had &lt;a href="http://tuesdaydeveloper.blogspot.com/2009/11/connecting-entity-beans-to-server.html"&gt;Eclipse create these for me&lt;/a&gt; and I didn't edit the code or the database at all, I was a bit confused. When I looked at the project file listings I noticed that Eclipse said all of the beans had compile errors in them.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Naturally I restarted Eclipse to see if that would help, nope. I then went to Project &gt; Clean and selected my EJB project, sure enough, all the errors when away.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Eclipse is a &lt;i&gt;wonderful&lt;/i&gt; tool, but even the best tools have their moments.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/702546477551195221-2251173910286648075?l=tuesdaydeveloper.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/9gwmEzICWDse4G5GeMDWVTdncUs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/9gwmEzICWDse4G5GeMDWVTdncUs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/9gwmEzICWDse4G5GeMDWVTdncUs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/9gwmEzICWDse4G5GeMDWVTdncUs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Tuesdaydeveloper/~4/3Hh24tHDuHc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://tuesdaydeveloper.blogspot.com/feeds/2251173910286648075/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://tuesdaydeveloper.blogspot.com/2009/11/eclipse-hint-clean-project.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/2251173910286648075?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/2251173910286648075?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Tuesdaydeveloper/~3/3Hh24tHDuHc/eclipse-hint-clean-project.html" title="Eclipse Hint: Clean Your Projects" /><author><name>Mahon</name><uri>http://www.blogger.com/profile/03453966321305664305</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="21" height="32" src="http://bp3.blogger.com/_1Pd7xJqxpjA/R9lQ2br37hI/AAAAAAAAAJI/J0aR0uuEN2s/S220/me-over-fire.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://tuesdaydeveloper.blogspot.com/2009/11/eclipse-hint-clean-project.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4EQXgycSp7ImA9WxNaEU8.&quot;"><id>tag:blogger.com,1999:blog-702546477551195221.post-5616241201144002394</id><published>2009-11-10T16:05:00.000-08:00</published><updated>2009-11-24T20:21:40.699-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-24T20:21:40.699-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="java ee" /><category scheme="http://www.blogger.com/atom/ns#" term="java 1.6" /><category scheme="http://www.blogger.com/atom/ns#" term="entity beans" /><category scheme="http://www.blogger.com/atom/ns#" term="database" /><title>Creating Java Entity Beans Dynamically from Database</title><content type="html">&lt;div&gt;What to create your entity beans dynamically?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;After you've created a new EJB Project in Eclipse and you have a database with tables, sequences, and relationships defined, it is quite easy to create your entity beans dynamically in Eclipse.&lt;div&gt;&lt;ol&gt;&lt;li&gt;Ensure that the JPS Tools are enabled.&lt;ol&gt;&lt;li&gt;Right click the EJB Project folder and select properties&lt;/li&gt;&lt;li&gt;On the left hand side of the properties window, select Project Facits&lt;/li&gt;&lt;li&gt;Check the Java Persistence checkbox&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;li&gt;Build the beans from the database.&lt;ol&gt;&lt;li&gt;Right click the EJB Project folder and select JPA Tools &gt; Generate Entities from Tables...&lt;/li&gt;&lt;li&gt;Ensure you are connected with the correct server and schema&lt;/li&gt;&lt;li&gt;Select the entity beans you want in your project.&lt;/li&gt;&lt;li&gt;Don't for get to tell it which package you want the beans in.&lt;/li&gt;&lt;li&gt;Click next until it asks you for the sequences for each bean and enter in the appropriate sequence generators.&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;li&gt;Click finish and it will build all the entity beans for you.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;The project will then build the beans for you assuming you have all the appropriate relationships etc.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Resources: Kent Jackson (&lt;a href="http://www.byui.edu/"&gt;BYU-Idaho&lt;/a&gt; Professor)&lt;/div&gt;&lt;div&gt;(Configuration: Eclipse Galileo for Java EE 6 using JBoss Server on Mac OS X 10.6 connecting to a VMware virtual machine with Windows running an academic licence version of Oracle)&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/702546477551195221-5616241201144002394?l=tuesdaydeveloper.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/pjAvQsSyPivTBJbnZ1LEMziDhPA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/pjAvQsSyPivTBJbnZ1LEMziDhPA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/pjAvQsSyPivTBJbnZ1LEMziDhPA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/pjAvQsSyPivTBJbnZ1LEMziDhPA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Tuesdaydeveloper/~4/B1lHiqEMMlI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://tuesdaydeveloper.blogspot.com/feeds/5616241201144002394/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://tuesdaydeveloper.blogspot.com/2009/11/connecting-entity-beans-to-server.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/5616241201144002394?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/5616241201144002394?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Tuesdaydeveloper/~3/B1lHiqEMMlI/connecting-entity-beans-to-server.html" title="Creating Java Entity Beans Dynamically from Database" /><author><name>Mahon</name><uri>http://www.blogger.com/profile/03453966321305664305</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="21" height="32" src="http://bp3.blogger.com/_1Pd7xJqxpjA/R9lQ2br37hI/AAAAAAAAAJI/J0aR0uuEN2s/S220/me-over-fire.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://tuesdaydeveloper.blogspot.com/2009/11/connecting-entity-beans-to-server.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUYGSH0-eSp7ImA9WxNbGE8.&quot;"><id>tag:blogger.com,1999:blog-702546477551195221.post-2891432421028203700</id><published>2009-01-06T00:01:00.000-08:00</published><updated>2009-11-21T09:05:29.351-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-21T09:05:29.351-08:00</app:edited><title>Disclaimer</title><content type="html">&lt;ul&gt;&lt;li&gt;People, programs, or robots who connect, read, view, think about, converse about, index, transcribe, copy for assignments, or anyone else who has anything whatsoever to do with this blog must accept these terms or they are not allowed to view them. If any of these entities view this site or use the information in any way they agree to these terms.&lt;/li&gt;&lt;li&gt;This site is not responsible for damage, loss, or other ill effects to computers, networks, hardware, users, household items, industrial items, consumption goods, durable hardware, small children, or anything else that bad advice can harm. You take suggestions at your own risk. (That said, I'm not going to put bad advice on here if I can help it, I just don't want anyone suing me for saying that they did what I told them to and it didn't work, or it caused their computer to lose it's memory, or it caused them to go bald.)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Blog comments that are spam, crude, have vulgar language (even mildly vulgar), are offensive, or otherwise inappropriate will summarily be deleted.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Links from this blog are not affiliated with this site or its entities unless otherwise stated.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;All content is copyrighted by the author of tuesdayDeveloper;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/702546477551195221-2891432421028203700?l=tuesdaydeveloper.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/VkBrQerFV5_UAm6-Khnnl8z5OfA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VkBrQerFV5_UAm6-Khnnl8z5OfA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/VkBrQerFV5_UAm6-Khnnl8z5OfA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VkBrQerFV5_UAm6-Khnnl8z5OfA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Tuesdaydeveloper/~4/0LQTe4FzMBA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://tuesdaydeveloper.blogspot.com/feeds/2891432421028203700/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://tuesdaydeveloper.blogspot.com/2009/01/disclaimer.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/2891432421028203700?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/2891432421028203700?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Tuesdaydeveloper/~3/0LQTe4FzMBA/disclaimer.html" title="Disclaimer" /><author><name>Mahon</name><uri>http://www.blogger.com/profile/03453966321305664305</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="21" height="32" src="http://bp3.blogger.com/_1Pd7xJqxpjA/R9lQ2br37hI/AAAAAAAAAJI/J0aR0uuEN2s/S220/me-over-fire.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://tuesdaydeveloper.blogspot.com/2009/01/disclaimer.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4DQHs7cSp7ImA9WxNbE04.&quot;"><id>tag:blogger.com,1999:blog-702546477551195221.post-4146819829823592236</id><published>2009-01-06T00:00:00.000-08:00</published><updated>2009-11-15T16:22:51.509-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-15T16:22:51.509-08:00</app:edited><title>Welcome</title><content type="html">This is the inaugural post for the tuesdayDeveloper Blog.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I started this blog because I've spent too many hours looking for the solutions. The problem is those solutions are way too scattered, and when you do find the answers, they aren't always comprehendible. So I'm putting the answers here, in an easy to understand list, in one place, where anyone can find it. Sure, I can't find all the answers, I don't expect to—I don't expect that every developer out there will find this useful—I'm still in college after all—there are undoubtedly developers with years more experience than I have. I can still do my part, and I can still make a few lives easier. I think programming is fun, I want others to feel the same.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You might ask why I call it t&lt;i&gt;uesday&lt;/i&gt;Developer? Because I thought the title was catchy. There is no other significance to it than that.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What types of things will I be posting? Solutions to any question I may have while I'm programming.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If someone wants to ask me a question will I answer it for them? Sure, if anyone has questions or suggestion let me know and I'll do my best to help you.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/702546477551195221-4146819829823592236?l=tuesdaydeveloper.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/q-iiTKOFHXLpecBlPVJoqn8ApoI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/q-iiTKOFHXLpecBlPVJoqn8ApoI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/q-iiTKOFHXLpecBlPVJoqn8ApoI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/q-iiTKOFHXLpecBlPVJoqn8ApoI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Tuesdaydeveloper/~4/F_Shh_tJdVo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://tuesdaydeveloper.blogspot.com/feeds/4146819829823592236/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://tuesdaydeveloper.blogspot.com/2009/11/inauguration.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/4146819829823592236?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/702546477551195221/posts/default/4146819829823592236?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Tuesdaydeveloper/~3/F_Shh_tJdVo/inauguration.html" title="Welcome" /><author><name>Mahon</name><uri>http://www.blogger.com/profile/03453966321305664305</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="21" height="32" src="http://bp3.blogger.com/_1Pd7xJqxpjA/R9lQ2br37hI/AAAAAAAAAJI/J0aR0uuEN2s/S220/me-over-fire.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://tuesdaydeveloper.blogspot.com/2009/11/inauguration.html</feedburner:origLink></entry></feed>

