Results 1 to 8 of 8

Thread: Show values

  1. #1
    Join Date
    Sep 2008
    Posts
    9

    Default Show values

    Hello

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

  2. #2
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Quote 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

  3. #3
    Join Date
    Mar 2007
    Location
    Poland
    Posts
    341

    Default

    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.

  4. #4
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Quote 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).

  5. #5
    Join Date
    Mar 2007
    Location
    Poland
    Posts
    341

    Default

    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]

  6. #6
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    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.

    Quote 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]

  7. #7
    Join Date
    Mar 2007
    Location
    Poland
    Posts
    341

    Default

    Quote 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.

  8. #8
    Join Date
    Sep 2008
    Posts
    9

    Default

    Quote 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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •