<?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>Simeon Says &#187; CFHibernate</title>
	<atom:link href="http://blog.simb.net/tag/CFHibernate/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.simb.net</link>
	<description>Because I said so...</description>
	<lastBuildDate>Tue, 31 Aug 2010 17:23:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>More on Hibernate in CF</title>
		<link>http://blog.simb.net/2005/05/26/more-on-hibernate-in-cf/</link>
		<comments>http://blog.simb.net/2005/05/26/more-on-hibernate-in-cf/#comments</comments>
		<pubDate>Thu, 26 May 2005 13:14:00 +0000</pubDate>
		<dc:creator>Simeon</dc:creator>
				<category><![CDATA[CF]]></category>
		<category><![CDATA[CFHibernate]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[So I have hibernate working with cf now.&#160; I am pretty happy with the results so far.&#160; But I have a real hang up about having to have all the config stuff in the classes directory inside the server.&#160; This is a large part of why I embarked on the classLoader.cfc.&#160; So what I found [...]]]></description>
			<content:encoded><![CDATA[<p>So I have hibernate working with cf now.&nbsp; I am pretty happy<br />
with the results so far.&nbsp; But I have a real hang up about having<br />
to have all the config stuff in the classes directory inside the<br />
server.&nbsp; This is a large part of why I embarked on the<br />
classLoader.cfc.&nbsp; So what I found was that i can get around that<br />
partly by utilizing the methods of the hibernate Configuration object.</p>
<p>By default when hibernate loads it looks in the classpath for its xml<br />
config and properties files.&nbsp; However buy using the addResource,<br />
addClass, addXml methods you can load up all that information with out<br />
the config files.&nbsp; So what I have done is drop my classes and<br />
class mapping files into the lib directory for my test website.&nbsp;<br />
After I initiate my hbConfig = org.hibernate.cfg.Configuration I can<br />
then use my classLoader.cfc to load the User class from my lib<br />
direcotry.&nbsp; Now as an object this doesnt do me alot of good. but<br />
by calling user.getClass() I have something I can pass into<br />
hbconfig.addClass().&nbsp; When I do this hibernate looks for the<br />
User.hbm.xml localling in the lib directory.&nbsp; And then continues<br />
execution happily.</p>
<p>So you might be thinking that we are set then, but that is not the<br />
case.&nbsp; When it comes time to create your session from which you<br />
will call your queries and such, it errors.&nbsp; It now tries to load<br />
the User object, but because cf loaded my hibernate config object, it<br />
looks for the User object on the classpath again.&nbsp; And seeing as<br />
that is what i am trying to not have to do, this throughs an error<br />
because the file is not there.</p>
<p>So i am thinking that if I can find some way to load the hibernate<br />
config object with my class loader then I could alleviate this<br />
problem.&nbsp; However I am not sure how to go about this<br />
exactly.&nbsp; Anybody have any ideas?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.simb.net/2005/05/26/more-on-hibernate-in-cf/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Hibernate in CF</title>
		<link>http://blog.simb.net/2005/05/23/using-hibernate-in-cf/</link>
		<comments>http://blog.simb.net/2005/05/23/using-hibernate-in-cf/#comments</comments>
		<pubDate>Mon, 23 May 2005 13:58:00 +0000</pubDate>
		<dc:creator>Simeon</dc:creator>
				<category><![CDATA[CFHibernate]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Hibernate is a an object/relational persistence and query service for Java.&#160; With Hibernate you create your model using POJO&#8217;s (Plain Old Java Objects) and configure an xml file per object to be persisted.&#160; So with the Hibernate libraries installed its very easy to instantiate a db session, populate your POJO, and pass that into a [...]]]></description>
			<content:encoded><![CDATA[<p><a target="_self" href="http://www.hibernate.org">Hibernate</a><br />
is a an object/relational persistence and query service for Java.&nbsp;<br />
With Hibernate you create your model using POJO&#8217;s (Plain Old Java<br />
Objects) and configure an xml file per object to be persisted.&nbsp; So<br />
with the Hibernate libraries installed its very easy to instantiate a<br />
db session, populate your POJO, and pass that into a save method in<br />
your session.&nbsp; Thats it.&nbsp; No inserts, no DAO code, just a<br />
couple calls and its done.&nbsp; And I want to do this from my cf<br />
apps.&nbsp; Seeing as there is a <a target="_self" href="http://groups.yahoo.com/group/cfhibernate/">group</a> devoted to just such a topic, I am not breaking any new ground here.&nbsp; In fact, all I have been working towards is making <a target="_self" href="http://www.mattwoodward.com">Matt Woodwards </a>example<br />
code (available to group members).&nbsp; And after a bundle of work I<br />
have finally succeeded.&nbsp; Read on to see what I had to do to make<br />
the demo application work.</p>
<p>The demo code that Matt released is a simple user manager<br />
application.&nbsp; In the Application.cfm we set up our application and<br />
then instantiate our hibernateConfig object into the application<br />
scope.&nbsp; Because the hibernate configuration regards our whole<br />
application, we dont need to worry about setting it up each request,<br />
just once per application load.&nbsp; Then for the example the next<br />
time we use hibernate is when we enter the user edit form.&nbsp; When<br />
you load the edit page we create a session using our hibernateConfig<br />
object in the application scope.&nbsp; Then using that seesion we pass<br />
in the criteria to retrieve our user (ID).&nbsp; This will retrieve the<br />
data from the database and actually return a user java object that is<br />
populated with our data.&nbsp; We can then use the getters on the user<br />
object to display the data for our form field.&nbsp; You can imagine<br />
how the update and delete process goes.&nbsp; If you would like to<br />
review the code to see what I am talking about, head over and join the<br />
cfhibernate group on yahoo groups.</p>
<p>So i hope by now you are thinking this sounds like something you would<br />
like to investigate further.&nbsp; I know that I was very eager to move<br />
forward.&nbsp; So I followed the only instructions that were available<br />
to me, the hibernate tutorial instructions.&nbsp; However as it turns<br />
out CF already uses several of the java libraries that hibernate tells<br />
you to install.&nbsp; As you might imagine this causes conflicts, and<br />
problems arise.&nbsp; Also the hibernate instructions tell you you need<br />
many more libs than are actually required for basic hibernate<br />
functionality.</p>
<p>I am doing this on my mac and so the j2ee installations are the only<br />
option.&nbsp; From my discussion with Matt he was able to get this<br />
running on the standalone install of cf7, but i dont know if that was<br />
linux or windows. &nbsp;</p>
<p>So I will walk you through what I did.&nbsp; First thing is to set up a<br />
new instance of cf in jrun.&nbsp; You dont have to but as we are going<br />
to be messing around in the core of CF, I figure its a good idea.&nbsp;<br />
The next step is to pick up the hibernate libraries from the<br />
Hibernate.org site.&nbsp; I pulled down the <a href="https://sourceforge.net/project/showfiles.php?group_id=40712&#038;package_id=127784" target="_self">3.0.4</a> set.&nbsp; Unzip<br />
these and travel into the created folder.&nbsp; Inside this folder you<br />
will see plenty of interesting things, and as yo learn more about<br />
hibernate some of it may be of use, however at this time we just need<br />
the hibernate3.jar file and some others inside the lib<br />
directory.&nbsp;&nbsp; These files (listed below) will need to be put<br />
in the {jrun-cf-instance}/cfusion/WEB-INF/cfusion/lib folder.&nbsp;<br />
Please copy these files:<br />
&nbsp; antlr.jar<br />
&nbsp; cglib-full.jar<br />
&nbsp; asm.jar<br />
&nbsp; asm-attrs.jars<br />
&nbsp; ehcache.jar<br />
&nbsp; hibernate3.jar<br />
&nbsp; jta.jar<br />
&nbsp; dom4j.jar<br />
Also for this demo application you will need the <a href="http://www.mysql.com/products/connector/j/" target="_self">mysql-connector-j</a> jar<br />
from the mysql site.&nbsp; But with those jars in place you are now<br />
ready to begin building applications with hibernate.</p>
<p>The next step is to set up our actual demo application.&nbsp; Once you<br />
have retrieved the zip file from the yahoo groups site you can unzip it<br />
into the document root for your cf instance.&nbsp; In that folder you<br />
will find a sql file, which contains the structure we will need in our<br />
test db.&nbsp; There is only one table and some dummy data in<br />
there.&nbsp; The application uses the dsn of cfhibernate, so you will<br />
need to set up a datasource in cf admin to connect to that new database.</p>
<p>The next files we need to work with are the actual hibernate config<br />
files.&nbsp; In the lib directory of the cfhibernate project<br />
(<a href="http://groups.yahoo.com/group/cfhibernate/" target="_self">downloaded from yahoo</a>) you will find 5 files.&nbsp; The one we are<br />
most concerned with is the hibernate.cfg.xml file.&nbsp; In side here<br />
you will see the configuration details for our db.&nbsp; This file<br />
tells Hibernate how to talk to our database.&nbsp; You will need to<br />
replace the information in the file with the same information you used<br />
to create our cf dsn.&nbsp; At the bottom of that file you will find an<br />
include of the User.hbm.xml.&nbsp; This is the xml file that maps how<br />
our java object will get persisted to the database.&nbsp; You can take<br />
a look at that if you are interested, but it doesnt require any<br />
changes.&nbsp; These files from the lib dir need to be copied to the<br />
classes directory in {jrun-cf-instance}/cfusion/WEB-INF/classes/.</p>
<p>Once you have these files in place you can restart your cf instance and<br />
navigate your your cfhibernate project.&nbsp; If the lib are in the<br />
right place the page will load and you should see a list of<br />
users.&nbsp; this page uses cfquery so nothing special has happened<br />
here yet.&nbsp; What you really want to do is click to edit&nbsp;<br />
user.&nbsp; This is where I was running into trouble.&nbsp; But if I<br />
managed to walk you through all the steps, and not ramble too much, you<br />
should see a form with that users information in the input boxes.&nbsp;<br />
If this is the case then you are set.&nbsp; you can update and delete<br />
the users, even add new ones.</p>
<p>This was a long post, and I am a bit tired, so I am very sorry if I<br />
ramble or if i have missed anything.&nbsp; I hope that in the near<br />
future, i can make this into a real howto and get more into the actual<br />
setup of the xml files and such.&nbsp; But i was very excited to have<br />
this working and I wanted to share.&nbsp; Let me know if you run into<br />
any troubles with my instructions and I will do my best to help you<br />
out.&nbsp; Obviously I am not an expert in Hibernate issues but I have<br />
spent several days getting this working, and i hope you will not have<br />
to do the same.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.simb.net/2005/05/23/using-hibernate-in-cf/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
