Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Spring + Hibernate  (Read 2935 times)
0 Members and 1 Guest are viewing this topic.
Offline ENC

Junior Member





« Posted 2006-10-17 09:11:55 »

I just came across the Spring Framework like only yesteryday. And found it to be a blast. W00t! Haha...

However I also do understand that Spring can link up with Hibernate in some ways.. the current Framework I linking with my databases.. can someone explain to me how?

Cheers!
Offline Mr_Light

Senior Member




shiny.


« Reply #1 - Posted 2006-10-17 10:29:09 »

It's not linked up as soon as your linking something in spring you go down a path of frustration and pain.

it is placed on top of the framework. the confusing bit that most ppl get lost in that springmvc is counted with the framework it's not(just part of the distribution.), its also placed on top of the framework.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline cylab

JGO Knight


Medals: 34



« Reply #2 - Posted 2006-10-17 12:10:31 »

I use Spring (with Tiles) and Hibernate at work and while it does offer some advantages for big projects, it has a steep learning curve and sometimes complicates simple things.

Mathias - I Know What [you] Did Last Summer!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline noblemaster

JGO Ninja


Medals: 19
Projects: 9


Age of Conquest makes your day!


« Reply #3 - Posted 2006-10-17 20:52:05 »

@cylab: what's your opinion on Hibernate? I used it  because I thought it is really cool the way you can map relational database tables with objects. But then, as you mentioned, there are tons of things that actually seem to make life harder compared to using PreparedStatement.

Offline Mr_Light

Senior Member




shiny.


« Reply #4 - Posted 2006-10-17 23:46:57 »

hibernate is nice profided you use xdoclet(or annotations I suppose) to generate hbm mappings. that and HQL is just great.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline ENC

Junior Member





« Reply #5 - Posted 2006-10-18 03:46:44 »

It's not linked up as soon as your linking something in spring you go down a path of frustration and pain.

it is placed on top of the framework. the confusing bit that most ppl get lost in that springmvc is counted with the framework it's not(just part of the distribution.), its also placed on top of the framework.

So I get you right... If I want to link Spring and Hibernate all I have to do is to configure Spring such that the Hibernate Componets will be covered?

Cheers!
Offline cylab

JGO Knight


Medals: 34



« Reply #6 - Posted 2006-10-18 07:21:48 »

@kingaschi
My opinion changes from day to day even after using hibernate for 2 years now Wink If everything goes well, hibernate is really great, if you have a bug, you curse the day you started with that mess. Smiley So I don't know if I like it. There is a nice abstraction for relations and such, but then again I constantly shooting myself in the foot with hibernate sessions, lazy loading, custom types etc. :/

@ENC
Yes:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
   <!-- This is an example for using hibernate with Annotations in spring -->
   <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
      <property name="dataSource">
         <ref local="dataSource"/>
      </property>
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
         </props>
      </property>
      <property name="annotatedClasses">
         <list>
            <value>[yourannotatedclass1]</value>
            <value>[yourannotatedclass2]</value>
            <value>[yourannotatedclassN]</value>
         </list>
      </property>
   </bean>

   <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName">
         <value>java:/[yourdatasource]<value>
      </property>
   </bean>

   <!-- Now you can use set the sessionFactory as property of your service class and use it to query the database -->
   <bean id="yourservice" class="[yourserviceclass]">
      <property name="sessionFactory">
         <ref local="sessionFactory"/>
      </property>
   </bean>
     

Mathias - I Know What [you] Did Last Summer!
Offline Mr_Light

Senior Member




shiny.


« Reply #7 - Posted 2006-10-18 09:28:22 »

your not using spring's stuff for transactions then cylab?

http://www.springframework.org/docs/reference/transaction.html

as long as I'm consistent in appling on wenn and how collections should be loaded I'm ok.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline cylab

JGO Knight


Medals: 34



« Reply #8 - Posted 2006-10-18 10:04:49 »

your not using spring's stuff for transactions then cylab?
I was not in the project I took the example from. Normally we do.

as long as I'm consistent in appling on wenn and how collections should be loaded I'm ok.
We persist a complete data model of a fairly complex application with a lot of interdependencies and some custom types using hibernate, so we mostly have to use lazy loading and reduce cascades to prevent hibernate from reading the whole database . What makes the situation worse is the use of hibernate enhanced data objects in form beans, so there are some catches, since the hibernate session could already be closed when accessing a lazy loaded property etc. etc.

(...)wenn(...)
Hallo Landsmann Wink

Mathias - I Know What [you] Did Last Summer!
Offline Mr_Light

Senior Member




shiny.


« Reply #9 - Posted 2006-10-18 23:46:36 »

Hallo Landsmann?  Huh

I'm probebly beeing dense.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cylab

JGO Knight


Medals: 34



« Reply #10 - Posted 2006-10-19 08:12:40 »

Hallo Landsmann?  Huh

I'm probebly beeing dense.
Nevermind, just a misconception. It's a common mistake for a german to write "wenn" instead of "when", so I thought you must be german.

Mathias - I Know What [you] Did Last Summer!
Offline Mr_Light

Senior Member




shiny.


« Reply #11 - Posted 2006-10-19 12:13:58 »

ne I'm dutch and dyslectic, so yer close.  Cool

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline cylab

JGO Knight


Medals: 34



« Reply #12 - Posted 2006-10-19 13:01:56 »

ne I'm dutch and dyslectic, so yer close.  Cool
LOL


Kiss Wink

Mathias - I Know What [you] Did Last Summer!
Offline ENC

Junior Member





« Reply #13 - Posted 2006-10-20 03:53:43 »

Another question... Spring and Hibernate are linked via XML correct? SO in that case

Struts , Spring and Hibernate also can be joint as one application correct? However my friend insist that is not possible cause he has tried. He even bet with me 300 bucks if I can come up with an application which conisist of all three frameworks together...

PS: I don't feel like losing 300 bucks  Undecided

Cheers!
Offline cylab

JGO Knight


Medals: 34



« Reply #14 - Posted 2006-10-20 08:07:51 »

http://www-128.ibm.com/developerworks/java/library/j-sr2.html

Mathias - I Know What [you] Did Last Summer!
Offline Mr_Light

Senior Member




shiny.


« Reply #15 - Posted 2006-10-20 23:22:57 »

Another question... Spring and Hibernate are linked via XML correct? SO in that case
IoC is configured though xml (most of the time, annotations are possible too)
 
Struts , Spring and Hibernate also can be joint as one application correct? However my friend insist that is not possible cause he has tried. He even bet with me 300 bucks if I can come up with an application which conisist of all three frameworks together...

PS: I don't feel like losing 300 bucks  Undecided

Cheers!

struts can be plugged into spring as a view component.  As I pointed out in my other msg in this thread try linking it and it will get messy, he probebly tried to start the spring container from struts. Which will work but leads to all kinds of issues.

http://64.233.183.104/search?q=cache:Q56Fv_ntmNAJ:www.springframework.org/node/267+spring+%226.+Birthdate+-+demonstrates+Struts+integration.%22&hl=en&ct=clnk&cd=1
also see the attachment I extracted the example from the release. (rename to birthdate.rar)

has anyone fiddled with JSR 170 and jackrabbit? I just came across it I found that the ppl at spring where already working on it http://forum.springframework.org/showthread.php?t=17763&page=3

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline ENC

Junior Member





« Reply #16 - Posted 2006-10-23 04:10:44 »

I renamed it... but cannot be open?
Offline Mr_Light

Senior Member




shiny.


« Reply #17 - Posted 2006-10-23 08:56:45 »

yeah it seems to be corrupted java-gaming.org seems quite unstable from here.

http://prdownloads.sourceforge.net/springframework/spring-webflow-1.0-rc4.zip

I though it was in there.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline ENC

Junior Member





« Reply #18 - Posted 2006-10-26 09:22:18 »

yeah it seems to be corrupted java-gaming.org seems quite unstable from here.

http://prdownloads.sourceforge.net/springframework/spring-webflow-1.0-rc4.zip

I though it was in there.

It seems that the classes which they use here are not from the original springframework is there any examples that uses from the default springframework... (Classes which are specified in SpringFramework 2.0)

By the way... I already lost my 300 bucks... so sad.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (31 views)
2014-04-15 18:08:23

BurntPizza (28 views)
2014-04-15 03:46:01

UprightPath (43 views)
2014-04-14 17:39:50

UprightPath (26 views)
2014-04-14 17:35:47

Porlus (43 views)
2014-04-14 15:48:38

tom_mai78101 (64 views)
2014-04-10 04:04:31

BurntPizza (124 views)
2014-04-08 23:06:04

tom_mai78101 (224 views)
2014-04-05 13:34:39

trollwarrior1 (190 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!