<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jeff Beard &#187; Software Development</title>
	<atom:link href="http://jeffbeard.org/category/computing/software-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeffbeard.org</link>
	<description>Blog.blog</description>
	<lastBuildDate>Sun, 01 Jan 2012 17:51:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Quick-n-dirty git getting started guide</title>
		<link>http://jeffbeard.org/2011/09/quick-n-dirty-git-getting-started-guide/</link>
		<comments>http://jeffbeard.org/2011/09/quick-n-dirty-git-getting-started-guide/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 21:24:17 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://jeffbeard.org/?p=404</guid>
		<description><![CDATA[As a git neophyte I approve of this post: http://news.ycombinator.com/item?id=2970637 UPDATE: I also found this helpful site: gitref.org]]></description>
			<content:encoded><![CDATA[<p>As a git neophyte I approve of this post:</p>
<p><a href="http://news.ycombinator.com/item?id=2970637">http://news.ycombinator.com/item?id=2970637</a></p>
<p>UPDATE: I also found this helpful site: <a href="http://gitref.org/">gitref.org</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jeffbeard.org/2011/09/quick-n-dirty-git-getting-started-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tip for optimizing MySQL data types</title>
		<link>http://jeffbeard.org/2011/06/tip-for-optimizing-mysql-data-types/</link>
		<comments>http://jeffbeard.org/2011/06/tip-for-optimizing-mysql-data-types/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 15:08:48 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[data management]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimizing data types]]></category>
		<category><![CDATA[refactoring databases]]></category>

		<guid isPermaLink="false">http://jeffbeard.org/?p=227</guid>
		<description><![CDATA[This is a tip that I&#8217;ve kept forgetting to write down so here it is: During a system&#8217;s life cycle requirements change and components are refactored. This includes databases as well and particularly as data grows. Decisions and assumptions are made at the beginning of a system&#8217;s life cycle that may or may not hold [...]]]></description>
			<content:encoded><![CDATA[<p>This is a tip that I&#8217;ve kept forgetting to write down so here it is:</p>
<p>During a system&#8217;s life cycle requirements change and components are refactored. This includes databases as well and particularly as data grows. Decisions and assumptions are made at the beginning of a system&#8217;s life cycle that may or may not hold up over years of operation and it&#8217;s good practice to continually analyze how well the initial design is working.<br />
<span id="more-227"></span><br />
When doing analysis in support of refactoring database schemas in MySQL, I&#8217;ve found this little bit of SQL to be invaluable.</p>
<p>Code:</p>
<pre class="brush: sql; title: ; notranslate">
SELECT * FROM TABLE PROCEDURE analyse();
</pre>
<p>(I suggest giving it a try on a small table with few rows.)</p>
<p><a href="http://dev.mysql.com/doc/refman/5.6/en/procedure-analyse.html">PROCEDURE ANALYSE</a> interrogates the values in a table, shows the smallest and largest values and suggests a type for each column. While the results frequently indicate that an ENUM type is the most appropriate you can add arguments to the ANALYSE procedure to get more rational suggestions. However, even with no arguments the results can be useful.</p>
<p>For example, you might see that the max value of a column actually is smaller than the type that it&#8217;s using. I&#8217;ve frequently seen INT(11) columns that would work fine as a MEDIUMINT or even TINYINT. Or your might find that an ENUM type is better since the distribution of values is small in a VARCHAR column. (The benefit of an ENUM is that the data is stored as an integer rather than the string value so its&#8217; footprint on the disk can be significantly smaller).</p>
<p>Anyway, while it&#8217;s not a panacea, PROCECURE ANALYSE() is another helpful tool.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffbeard.org/2011/06/tip-for-optimizing-mysql-data-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;select count&#8221; with Generics, Spring and Hibernate</title>
		<link>http://jeffbeard.org/2011/04/select-count-with-generics-spring-and-hibernate/</link>
		<comments>http://jeffbeard.org/2011/04/select-count-with-generics-spring-and-hibernate/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 12:57:44 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[generics]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[spring framework]]></category>

		<guid isPermaLink="false">http://jeffbeard.org/?p=209</guid>
		<description><![CDATA[In a recent project, we introduced Generics and Spring into an application. In developing the Generic DAO implementation I was trying to find a way to get a record count from the database. It&#8217;s a simple enough task with HQL or Spring&#8217;s JdbcTemplate.queryForInt(String sql), however the Generics made it a little tricky. The solution I [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent project, we introduced Generics and Spring into an application. In developing the Generic DAO implementation I was trying to find a way to get a record count from the database. It&#8217;s a simple enough task with HQL or Spring&#8217;s <a href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/jdbc/core/JdbcTemplate.html">JdbcTemplate</a>.<a href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/jdbc/core/JdbcTemplate.html#queryForInt%28java.lang.String%29">queryForInt(String sql)</a>, however the Generics made it a little tricky. The solution I came up with was using <a title="HibernateCallback" href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/orm/hibernate3/HibernateCallback.html">HibernateCallback</a>. A reference to the persistent type is a member of GenericDAOHibernate as is the <a href="http://docs.jboss.org/hibernate/core/3.3/api/org/hibernate/SessionFactory.html">SessionFactory</a> and an instance of Spring&#8217;s <a href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/orm/hibernate3/HibernateTemplate.html">HibernateTemplate</a>.</p>
<p><span id="more-209"></span></p>
<pre class="brush: java; title: ; notranslate">
public class GenericDAOHibernate&lt;T, PK extends Serializable&gt; implements GenericDAO&lt;T, PK&gt; {

	/** log4j Logger for class GenericDAOHibernate */
	private static Logger logger = Logger.getLogger(GenericDAOHibernate.class.getName());

    private Class&lt;T&gt; persistentClass;

    private HibernateTemplate hibernateTemplate;

    @Autowired(required=true)
    private SessionFactory sessionFactory;

// [...]

@Override
public Class&lt;T&gt; getPersistentClass() {
    return persistentClass;
}

@Override
public int countAll() {

    @SuppressWarnings({ &quot;unchecked&quot;, &quot;rawtypes&quot; })
    List results = (List) hibernateTemplate.execute(new HibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            return session.createCriteria(getPersistentClass())
                .setProjection(Projections.rowCount())
                .list();
            }
        });

        // Here I use the Spring DataAccessUtils class to interpret the result set
        int result = DataAccessUtils.intResult(results)

        logger.debug(&quot;count retrieved: &quot; + result;

        return result;
}
</pre>
<p>I also added another convenience method that uses the <a href="http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querycriteria.html#querycriteria-examples">Example Criteria API</a> so we can generate a count with a pre-configured Entity:</p>
<pre class="brush: java; title: ; notranslate">
@Override
public int countByExample(final T exampleInstance)

    @SuppressWarnings({ &quot;unchecked&quot;, &quot;rawtypes&quot; })
    List results = (List) hibernateTemplate.execute(new HibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            return session.createCriteria(getPersistentClass())
                .add(Example.create(exampleInstance))
                .setProjection(Projections.rowCount())
                .list();
            }
        });

        // Here I use the Spring DataAccessUtils class to interpret the result set
        int result = DataAccessUtils.intResult(results)

        logger.debug(&quot;count retrieved: &quot; + result;

        return result;
</pre>
<p>I plan to package up some of the Generics code at some point and will post a link to download it or to a public source code repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffbeard.org/2011/04/select-count-with-generics-spring-and-hibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using memcached
Object Caching 252/314 objects using memcached

Served from: jeffbeard.org @ 2012-02-05 13:24:44 -->
