In Hibernate, the corresponding file column type can be org. springframework. orm. hibernate3.support. BlobByteArrayType,
Org. springframework. orm. hibernate3.support. ClobStringType, clob, blob, and binary. When to use BlobBYteArrayType
When should I use ClobStringType? Generally, if the object to be processed is blob in the database field type (mainly images and binary objects ),
The ing file is set to org. springframework. orm. hibernate3.support. BlobByteArrayType. The database field is clob (large Text object)
Type, set the java attribute type to String, and set the ing file to org. springframework. orm. hibernate3.support. ClobStringType.
4. If you want to use the Struts self-contained upload function on spring, it must be declared in the spring configuration file. Will it appear in the configuration file?
Ava. lang. IllegalStateException:No LobHandler Found ForConfiguration-LobHandlerProperty
Must be set on LocalSessionFactoryBean exception. The configuration is as follows:
(1) declare a processing handle:
<Bean id ="LobHandler"Class =" org. springframework. jdbc. support. lob. DefaultLobHandler "lazy-init =" true "/>
(2). Inject in sessionFactoryLobHandler:
<Bean id = "sessionFactory" class = "org. springframework. orm. hibernate3.LocalSessionFactoryBean">
<Property name ="LobHandler"Ref ="LobHandler"/>
</Bean>
Tip: SpecifyLobHandlerFor MySQL, DB2, ms SQL Server, Oracle 10 Gb, use DefaultLobHandler, and Oracle 9i,
You can use OracleLobHandler. Because Oracle9i processes lob in a different way, we need to use the SimpleNativeJdbcExtractor provided by spring to process special declarations of the Oracle9i lob type:
<Bean id = "nativeJdbcExtractor" lazy-init = "true" class = "org. springframework. jdbc. support. nativejdbc.
SimpleNativeJdbcExtractor "/>
<Bean id ="LobHandler"Lazy-init =" true "class =" org. springframework. jdbc. support. lob. OracleLobHandler ">
<Property name = "nativeJdbcExtractor">
<Ref bean = "nativeJdbcExtractor"/>
</Property>
</Bean>
<Bean id = "sessionFactory" class = "org. springframework. orm. hibernate3.LocalSessionFactoryBean">
<! -- Handle declaration for processing Blob fields -->
<Property name ="LobHandler">
<Ref local ="LobHandler"/>
</Property>
</Bean>
The corresponding JDBC driver should also be used.
Clob field definition: <property name = "attribute name" column = "column name" type = "org. springframework. orm. hibernate. support. ClobStringType"
Length = "1048"/> the length here refers to the byte, which can be up to 2 GB. This field is declared as String type in the java object.
If mysql database is used, the default size of the uploaded file is only 1047552 bytes. If the uploaded file is larger than 1047552 bytes, an exception occurs.
Org. springframework. jdbc. UncategorizedSQLException: You can change this value on the server by setting
The max_allowed_packet 'variable. You can modify the max_allowed_packet attribute size of the mysql database as prompted.
Open the my. ini file, find # server section, and add max_allowed_packet =? Under port = 3306? After M is modified, restart the mysql service to upload the file.