Permalink
Browse files

* Things

  • Loading branch information...
1 parent ff6826a commit bd45b798f9abf25d7ff713668dbeeb3e16ca38ab Jonathan Garay committed Feb 9, 2012
@@ -31,11 +31,16 @@ public EntityManager getEntityManager(){
}
- public void persist(Serializable object){
+ public void persist(Serializable object) throws Exception {
EntityManager entityManager = getEntityManager();
- entityManager.getTransaction().begin();
- entityManager.persist(object);
- entityManager.getTransaction().commit();
+ try{
+ entityManager.getTransaction().begin();
+ entityManager.persist(object);
+ entityManager.getTransaction().commit();
+ }catch(Exception ex){
+ entityManager.getTransaction().rollback();
+ throw new Exception(ex);
+ }
}
public void persist(Serializable... objects){
@@ -26,9 +26,8 @@
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String login(User user, Model model, RedirectAttributes redirectAttributes) {
- EntityManager em = getEntityManager();
- User loginUser = (User) em.createNamedQuery("user.find.to_login")
+ User loginUser = (User) getEntityManager().createNamedQuery("user.find.to_login")
.setParameter("username", user.getUsername())
.setParameter("password", user.getPassword())
.getSingleResult();
@@ -37,7 +37,11 @@ public String newUser(Model model){
@RequestMapping(method = RequestMethod.POST)
public String create(@Valid User user, BindingResult result,RedirectAttributes redirectAttributes){
if(result.hasErrors()){ return "accounts/new"; }
- persist(user);
+ try {
+ persist(user);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
tuitSession.login(user);
return "redirect:/user/dashboard";
@@ -68,7 +72,11 @@ public String dashboard(Model model){
@RequestMapping(value = "/tuit", method = RequestMethod.POST)
public @ResponseBody Tuit newTuit(@Valid Tuit tuit, BindingResult result, Model model){
tuit.setUser(tuitSession.getCurrentUser());
- persist(tuit);
+ try {
+ persist(tuit);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return tuit;
}
View
@@ -37,12 +37,9 @@
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target/classes" />
<excludeFolder url="file://$MODULE_DIR$/target/dependency" />
- <excludeFolder url="file://$MODULE_DIR$/target/m2e-wtp" />
<excludeFolder url="file://$MODULE_DIR$/target/maven-archiver" />
<excludeFolder url="file://$MODULE_DIR$/target/surefire" />
- <excludeFolder url="file://$MODULE_DIR$/target/test-classes" />
<excludeFolder url="file://$MODULE_DIR$/target/tmp" />
- <excludeFolder url="file://$MODULE_DIR$/target/tomcat" />
<excludeFolder url="file://$MODULE_DIR$/target/tuit-1.0-SNAPSHOT" />
</content>
<orderEntry type="inheritedJdk" />
@@ -85,6 +82,8 @@
<orderEntry type="library" name="Maven: org.javassist:javassist:3.15.0-GA" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-entitymanager:4.0.1.Final" level="project" />
+ <orderEntry type="library" name="Maven: org.hibernate:hibernate-c3p0:4.0.1.Final" level="project" />
+ <orderEntry type="library" name="Maven: c3p0:c3p0:0.9.1" level="project" />
<orderEntry type="library" name="Maven: hsqldb:hsqldb:1.8.0.7" level="project" />
<orderEntry type="library" name="Maven: commons-dbcp:commons-dbcp:1.4" level="project" />
<orderEntry type="library" name="Maven: commons-pool:commons-pool:1.5.4" level="project" />
View
@@ -1002,6 +1002,8 @@
<element id="library" level="project" name="Maven: org.javassist:javassist:3.15.0-GA" />
<element id="library" level="project" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.1.Final" />
<element id="library" level="project" name="Maven: org.hibernate:hibernate-entitymanager:4.0.1.Final" />
+ <element id="library" level="project" name="Maven: org.hibernate:hibernate-c3p0:4.0.1.Final" />
+ <element id="library" level="project" name="Maven: c3p0:c3p0:0.9.1" />
<element id="library" level="project" name="Maven: hsqldb:hsqldb:1.8.0.7" />
<element id="library" level="project" name="Maven: commons-dbcp:commons-dbcp:1.4" />
<element id="library" level="project" name="Maven: commons-pool:commons-pool:1.5.4" />
@@ -1283,6 +1285,17 @@
<root url="jar://$MAVEN_REPOSITORY$/asm/asm/3.1/asm-3.1-sources.jar!/" />
</SOURCES>
</library>
+ <library name="Maven: c3p0:c3p0:0.9.1">
+ <CLASSES>
+ <root url="jar://$MAVEN_REPOSITORY$/c3p0/c3p0/0.9.1/c3p0-0.9.1.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$MAVEN_REPOSITORY$/c3p0/c3p0/0.9.1/c3p0-0.9.1-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$MAVEN_REPOSITORY$/c3p0/c3p0/0.9.1/c3p0-0.9.1-sources.jar!/" />
+ </SOURCES>
+ </library>
<library name="Maven: cglib:cglib:2.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/cglib/cglib/2.2/cglib-2.2.jar!/" />
@@ -1492,6 +1505,17 @@
<root url="jar://$MAVEN_REPOSITORY$/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final-sources.jar!/" />
</SOURCES>
</library>
+ <library name="Maven: org.hibernate:hibernate-c3p0:4.0.1.Final">
+ <CLASSES>
+ <root url="jar://$MAVEN_REPOSITORY$/org/hibernate/hibernate-c3p0/4.0.1.Final/hibernate-c3p0-4.0.1.Final.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$MAVEN_REPOSITORY$/org/hibernate/hibernate-c3p0/4.0.1.Final/hibernate-c3p0-4.0.1.Final-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$MAVEN_REPOSITORY$/org/hibernate/hibernate-c3p0/4.0.1.Final/hibernate-c3p0-4.0.1.Final-sources.jar!/" />
+ </SOURCES>
+ </library>
<library name="Maven: org.hibernate:hibernate-core:4.0.1.Final">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/hibernate/hibernate-core/4.0.1.FINAL/hibernate-core-4.0.1.FINAL.jar!/" />
Oops, something went wrong.

0 comments on commit bd45b79

Please sign in to comment.