Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Scriptrunner for Confluence: HibernateJdbcException

Niklas Kordasch October 5, 2022

Dear Community,

My code is throwing me an HibernateJdbcException. However, I am only reading the data, saving it to a list.

The goal is to set a label based on the PageProperties. The simplified code is below

 


Code:

DatabaseUtil.withSql('Confluence DB') { sql ->
    sql.query("SELECT c.contentid FROM content c JOIN bodycontent bc ON c.contentid = bc.contentid JOIN content_label cl ON cl.contentid = c.contentid JOIN label l ON l.labelid = cl.labelid WHERE l.name = ${label} AND content_status = ${status} and bc.body like ${bodyStatus};") { resultSet ->
       
        while (resultSet.next()) {
            pageIDs.add(resultSet.getString('contentid').toLong())

                   
            }
        }
    }
    currentPage = pageManager.getPage(97384929)
    labelManager.addLabel(currentPage,new Label("Test"))
Error:
org.springframework.orm.hibernate5.HibernateJdbcException: JDBC exception on Hibernate data access: SQLException for SQL [n/a]; SQL state [25P02]; error code [0]; could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:219) at org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:374) at org.springframework.orm.hibernate5.HibernateTemplate.execute(HibernateTemplate.java:320) at com.atlassian.confluence.labels.persistence.dao.hibernate.HibernateLabelDao.findContentCountForLabel(HibernateLabelDao.java:759) at com.atlassian.confluence.labels.DefaultLabelManager.getContentCount(DefaultLabelManager.java:707) at com.atlassian.confluence.labels.DefaultLabelManager.internalRemove(DefaultLabelManager.java:174) at com.atlassian.confluence.labels.DefaultLabelManager.removeLabel(DefaultLabelManager.java:183) at com.atlassian.confluence.impl.labels.CachingLabelManager.removeLabel(CachingLabelManager.java:117) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
Does somebody have an idea?

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Craig Nodwell
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 7, 2022

Hi @Niklas Kordasch I think this post might have your answer.

Niklas Kordasch October 10, 2022

Hey @Craig Nodwell thank you. 

My SQL query does not seem to close. I set the label with the LabelManager, which does not access the query.
The query runs without the LabelManager without problems.
Without the query the LabelManager also works.

There should be query and LabelManager working independently.

Current exception:
org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:870)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:707)
at jdk.internal.reflect.GeneratedMethodAccessor118.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
at com.sun.proxy.$Proxy82.commit(Unknown Source)


Thanks for your help,

Niklas

TAGS
AUG Leaders

Atlassian Community Events