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 581527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:35:18+00:00 2026-05-13T14:35:18+00:00

Does anyone know how what Spring Jdbc template method I could use to execute

  • 0

Does anyone know how what Spring Jdbc template method I could use to execute this ‘upsert’ or an alternative approach that would also perform the operations in one database call?

UPDATE jasper_report SET Uri = 'update' WHERE ReportId = 99;
IF @@ROWCOUNT = 0 AND Exists(Select 1 FROM report Where Id = 99)
BEGIN   
    INSERT INTO jasper_report  (ReportId, Uri) VALUES (99, 'insert') 
END;
  • 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-13T14:35:18+00:00Added an answer on May 13, 2026 at 2:35 pm

    Turns out I was close but forget a step.

    I had to change the query itself to:

    BEGIN 
      UPDATE jasper_report SET Uri = ? WHERE ReportId = ? 
      IF @@ROWCOUNT = 0 AND EXISTS(SELECT 1 FROM report WHERE Id = ?) 
      BEGIN 
           INSERT INTO jasper_report  (ReportId, Uri) VALUES (?, ?) 
      END 
    END
    

    Then in my Dao only needed to use Spring’s JdbcTemplate update method. It looks something like this:

    @Repository("jasperReportsDao")
    public class JasperReportsDaoImpl extends JdbcTemplate implements JasperReportsDao {
    
        @Override
        public void saveJasperReport(JasperReport report) {
            // If a record already exists, do an update, otherwise, do an insert
            int rowsAffected = this.update(UPSERT_JASPER_REPORT, new Object[] { report.getUri(), report.getId(),
                                   report.getId(), report.getId(), report.getUri()} );
    
            if(log.isDebugEnabled()) { log.debug("Rows affected: " + rowsAffected); }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 514k
  • Answers 514k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The reason you're seeing this seemingly "strange" behaviour is that… May 16, 2026 at 6:19 pm
  • Editorial Team
    Editorial Team added an answer I have no definite answer for you, but you may… May 16, 2026 at 6:19 pm
  • Editorial Team
    Editorial Team added an answer You would usually write the query as select emp from… May 16, 2026 at 6:19 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Does anyone know if there any way that I can programmatically create a bean
Does anyone know why in Firefox if you execute the code below it will
Does anyone know how to use the RegisterHotKey/UnregisterHotKey API calls in a console application?
I have the above-mentioned error in s1=some very long string............ Does anyone know what
Does anyone know of an efficient implementation of a memcspn function?? It should behave
Using Spring 1.2.1 and oracle.jdbc.pool.OracleDataSource 10.2.0.3.0 I sometimes get a stack trace like below.
I am using spring-2.5.6 to connect from a standalone application to an Oracle 10g
I have an extremely simple web application running in Tomcat using Spring 3.0.2, Hibernate
I’d like to know if standard JS provides a way of splitting a string
i have a string like this somestring='in this/ string / i have many. interesting.occurrences

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.