Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7631857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:27:51+00:00 2026-05-31T06:27:51+00:00

I’ve spent about 8 hours researching and I cannot find a solution so I’m

  • 0

I’ve spent about 8 hours researching and I cannot find a solution so I’m creating my first post here!

I’m getting the following error when hitting the getVote function as the object doesn’t return anything.

java.lang.NullPointerException
at com.client.dao.impl.VoteDaoImpl.getVote(VoteDaoImpl.java:51)
at com.client.dao.impl.VoteDaoImpl.incrementVote(VoteDaoImpl.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy125.incrementVote(Unknown Source)
at com.client.action.VoteActionImpl.execute(VoteActionImpl.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)

Doing this:
Query query=currentSession().createQuery(“from com.gasx.model.Vote where id=?”);
Returns an object but it doesn’t appear to function correctly (my logging stops).
Config looks like this. First time using annotations.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
   http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/tx
   http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.0.xsd
   ">

   <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
            destroy-method="close">
            <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
            <property name="url" value="jdbc:oracle:thin:@localhost:1521:orcldb" />
            <property name="username" value="client" />
            <property name="password" value="client" />
   </bean>

   <bean id="sessionFactory"
                 class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <!--property name="packagesToScan" value="com.client.model" /-->
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
                    <prop key="hibernate.hbm2ddl.auto">create</prop>
                    <prop key="hibernate.show_sql">true</prop>    
                    <!--prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop-->
                    <prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop>                
                </props>
            </property>
            <property name="annotatedClasses">
                <list>
                    <value>com.client.model.Vote</value>                        
                </list>
            </property>

    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>



    <bean id="voteDao" class="com.client.dao.impl.VoteDaoImpl" />

    <bean id="voteAction" class="com.client.action.VoteActionImpl">
        <property name="voteDao" ref="voteDao" />
    </bean>

    <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>     
    <tx:annotation-driven transaction-manager="transactionManager" />   
    <context:annotation-config />   
    <context:component-scan base-package="com.client.dao.impl" />
</beans>     

DAO Implementation

package com.client.dao.impl;

import org.apache.log4j.Logger;

import com.client.dao.VoteDao;
import com.client.model.Vote;

import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional
public class VoteDaoImpl implements VoteDao{
private static Logger logger=Logger.getLogger(VoteDaoImpl.class);
//private Vote voteBean;
private SessionFactory sessionFactory;

/**
 * @return the sessionFactory
 */

private Session currentSession(){
    return sessionFactory.getCurrentSession();
}

@Autowired
public VoteDaoImpl(SessionFactory sessionFactory){
    this.sessionFactory=sessionFactory;
}

public Vote getVote(int id){
    logger.info("getVote");
    //Query query=currentSession().createQuery("from com.client.model.Vote where id=?");
    //setParameter(0, id).list().get(0);

    Session session = currentSession();
    Vote vote=(Vote)session.get(Vote.class, id);


/*      if (vote==null){
        logger.info("Object was null");
    }else{
        logger.info("Object isn't null!");
    }
    */
    logger.info("Vote total: " + String.valueOf(vote.getVoteTotal()));
    return vote;
}

public void updateVote(Vote vote){
    currentSession().update(vote);      
    currentSession().flush();
}

/*
 * 
 * incements the vote.id=id 
 * 
 */
public void incrementVote(int id){
    logger.info(" increment vote");
    Vote vote=getVote(id);
    vote.setVoteTotal(vote.getVoteTotal()+1);
    updateVote(vote);

}
}

Model

package com.client.model;
import com.client.dao.*;
import javax.persistence.Column;
import javax.persistence.Entity;
//import org.hibernate.annotations.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="vote")
public class Vote {

@Id
@Column(name="id")
private int id;

@Column(name="vote_total")
private int voteTotal;

/**
 * @return the id
 */

public int getId() {
    return id;
}

/**
 * @param id the id to set
 */
public void setId(int id) {
    this.id = id;
}

/**
 * @return the voteTotal
 */

public int getVoteTotal() {
    return voteTotal;
}

/**
 * @param vote1Total
 *            the vote1Total to set
 */
public void setVoteTotal(int voteTotal) {
    this.voteTotal = voteTotal;
}
}

There is an interface for the dao

package com.client.dao;

import org.hibernate.classic.Session;

import com.client.model.Vote;


public interface VoteDao {
public Vote getVote(int id);
public void updateVote(Vote vote);
public void incrementVote(int id);
}

Any ideas? I’m stumped. If you need any info please let me know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:27:55+00:00Added an answer on May 31, 2026 at 6:27 am

    The project was okay… The issue was I forgot that in oracle you have to commit. I was inserting my seed data but the app couldn’t see it as it was never committed. Cannot believe I did that… It has been a couple years since I worked with oracle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.