File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed 
hibernate-community-dialects/src/main/java/org/hibernate/community/dialect Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 1717import  org .hibernate .boot .model .TypeContributions ;
1818import  org .hibernate .community .dialect .identity .GaussDBIdentityColumnSupport ;
1919import  org .hibernate .community .dialect .sequence .GaussDBSequenceSupport ;
20+ import  org .hibernate .dialect .BooleanDecoder ;
2021import  org .hibernate .dialect .Dialect ;
2122import  org .hibernate .dialect .DatabaseVersion ;
2223import  org .hibernate .dialect .DmlTargetColumnQualifierSupport ;
@@ -445,9 +446,28 @@ public String castPattern(CastType from, CastType to) {
445446		if  ( from  == CastType .STRING  && to  == CastType .BOOLEAN  ) {
446447			return  "cast(?1 as ?2)" ;
447448		}
448- 		else  {
449- 			return  super .castPattern ( from , to  );
449+ 
450+ 		if  ( to  == CastType .STRING  ) {
451+ 			switch  ( from  ) {
452+ 				case  BOOLEAN :
453+ 				case  INTEGER_BOOLEAN :
454+ 				case  TF_BOOLEAN :
455+ 				case  YN_BOOLEAN :
456+ 					return  BooleanDecoder .toString ( from  );
457+ 				case  DATE :
458+ 					return  "to_char(?1,'YYYY-MM-DD')" ;
459+ 				case  TIME :
460+ 					return  "cast(?1 as ?2)" ;
461+ 				case  TIMESTAMP :
462+ 					return  "to_char(?1,'YYYY-MM-DD HH24:MI:SS.FF9')" ;
463+ 				case  OFFSET_TIMESTAMP :
464+ 					return  "to_char(?1,'YYYY-MM-DD HH24:MI:SS.FF9TZH:TZM')" ;
465+ 				case  ZONE_TIMESTAMP :
466+ 					return  "to_char(?1,'YYYY-MM-DD HH24:MI:SS.FF9 TZR')" ;
467+ 			}
450468		}
469+ 
470+ 		return  super .castPattern ( from , to  );
451471	}
452472
453473	/** 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments