Announcement Announcement Module
Collapse
No announcement yet.
Show values Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Show values

    Hello

    how to achieve that hibernate shows inserted values? hibernate.show_sql shows just executed statement!

  • #2
    Originally posted by robertsv View Post
    Hello

    how to achieve that hibernate shows inserted values? hibernate.show_sql shows just executed statement!
    AFAIK no way

    Comment


    • #3
      No way.

      You can enable another category in hibernate (i think it is package suffixed by "Types") and than you can see how '?' are mapped to values.

      Anyway it does not look clear.

      In my project i used to use p6spy - quite old and buggy, to show me full SQL i can just copy.
      I am just using it only on my test environment - P6Spy is not production ready.

      Comment


      • #4
        Originally posted by miluch View Post
        No way.

        You can enable another category in hibernate (i think it is package suffixed by "Types") and than you can see how '?' are mapped to values.
        May you be more specific? I sounds interesting, but AFAIK all Hibernate configuration settings are centralized on org.hibernate.cfg.Configuration and there no such setting exists (at least for 3.2).

        Comment


        • #5
          Sorry i did not express clearly in my last post.

          I thought that robertsv just wanted to capture SQL statements as is.
          hibernate.show_sql just show sql in a preparedStatement format (with ? as query parameters).
          You can set
          Code:
          	<category name="org.hibernate.SQL">
          		<level value="DEBUG" />
          		<appender-ref ref="HIBERNATE_SPRING" />
          	</category>
          
          	<category name="org.hibernate.type">
          		<level value="trace" />
          		<appender-ref ref="HIBERNATE_SPRING" />
          	</category>
          In log4j configuration file to find out how query(or insert looked like):
          Code:
          2008-09-18 14:37:43,343 DEBUG  - 
              /* insert pl.model.CallCenterDialogue
                  */ insert 
                  into
                      CALL_CENTER_DIALOGUE"
                      (CCD_USER_ID, "CCD_LAST_ACTIVITY_DATE", "CCD_CONVERS_START_DATE", "CCD_CONVERS_STATUS", "CCD_CONVERS_TOKEN", "FORCE_NEW", "CCD_LOGIN_STATUS", CCD_PART_ID, "CCD_ID") 
                  values
                      (?, ?, ?, ?, ?, ?, ?, ?, ?) [log=SQL]
          2008-09-18 14:37:43,343 TRACE  - binding '90' to parameter: 1 [log=LongType]
          2008-09-18 14:37:43,343 TRACE  - binding '2008-09-18 14:37:43' to parameter: 2 [log=TimestampType]
          2008-09-18 14:37:43,343 TRACE  - binding '2008-09-18 14:37:43' to parameter: 3 [log=TimestampType]
          2008-09-18 14:37:43,343 TRACE  - binding 'SYN' to parameter: 4 [log=StringType]
          2008-09-18 14:37:43,343 TRACE  - binding 'ffffffa975774720361e361eacf1613d' to parameter: 5 [log=StringType]
          2008-09-18 14:37:43,343 TRACE  - binding 'true' to parameter: 6 [log=YesNoType]
          2008-09-18 14:37:43,343 TRACE  - binding 'AUTHENTICATED' to parameter: 7 [log=StringType]
          2008-09-18 14:37:43,343 TRACE  - binding '1000000000' to parameter: 8 [log=LongType]
          2008-09-18 14:37:43,343 TRACE  - binding '806' to parameter: 9 [log=LongType]

          Comment


          • #6
            Thank you very much!

            The funniest thing that I have used it myself some (relatively long) time ago, but completely forgot about it, so stupid for me .

            BTW, Category is deprecated in log4j, Logger should be preferred instead.

            Originally posted by miluch View Post
            Sorry i did not express clearly in my last post.

            Code:
            	<category name="org.hibernate.SQL">
            		<level value="DEBUG" />
            		<appender-ref ref="HIBERNATE_SPRING" />
            	</category>
            
            	<category name="org.hibernate.type">
            		<level value="trace" />
            		<appender-ref ref="HIBERNATE_SPRING" />
            	</category>
            In log4j configuration file to find out how query(or insert looked like):
            Code:
            2008-09-18 14:37:43,343 DEBUG  - 
                /* insert pl.model.CallCenterDialogue
                    */ insert 
                    into
                        CALL_CENTER_DIALOGUE"
                        (CCD_USER_ID, "CCD_LAST_ACTIVITY_DATE", "CCD_CONVERS_START_DATE", "CCD_CONVERS_STATUS", "CCD_CONVERS_TOKEN", "FORCE_NEW", "CCD_LOGIN_STATUS", CCD_PART_ID, "CCD_ID") 
                    values
                        (?, ?, ?, ?, ?, ?, ?, ?, ?) [log=SQL]
            2008-09-18 14:37:43,343 TRACE  - binding '90' to parameter: 1 [log=LongType]
            2008-09-18 14:37:43,343 TRACE  - binding '2008-09-18 14:37:43' to parameter: 2 [log=TimestampType]
            2008-09-18 14:37:43,343 TRACE  - binding '2008-09-18 14:37:43' to parameter: 3 [log=TimestampType]
            2008-09-18 14:37:43,343 TRACE  - binding 'SYN' to parameter: 4 [log=StringType]
            2008-09-18 14:37:43,343 TRACE  - binding 'ffffffa975774720361e361eacf1613d' to parameter: 5 [log=StringType]
            2008-09-18 14:37:43,343 TRACE  - binding 'true' to parameter: 6 [log=YesNoType]
            2008-09-18 14:37:43,343 TRACE  - binding 'AUTHENTICATED' to parameter: 7 [log=StringType]
            2008-09-18 14:37:43,343 TRACE  - binding '1000000000' to parameter: 8 [log=LongType]
            2008-09-18 14:37:43,343 TRACE  - binding '806' to parameter: 9 [log=LongType]

            Comment


            • #7
              Originally posted by al0 View Post
              Thank you very much!

              The funniest thing that I have used it myself some (relatively long) time ago, but completely forgot about it, so stupid for me .

              BTW, Category is deprecated in log4j, Logger should be preferred instead.
              No problem.
              Fact, i will change category to logger.

              One thing that has also changed in Hibernate version 3 is using Trace level to printout parameter binding.
              In a previous version DEBUG was enough.

              Comment


              • #8
                Originally posted by miluch View Post
                No problem.
                Fact, i will change category to logger.

                One thing that has also changed in Hibernate version 3 is using Trace level to printout parameter binding.
                In a previous version DEBUG was enough.
                yeh it is working. I changed logging level to TRACE. Thx!

                Comment

                Working...
                X