read-only="true"

如果你一次执行单条查询语句,则没有必要启用事务支持,数据库默认支持SQL执行期间的读一致性;

如果你一次执行多条查询语句,例如统计查询,报表查询,在这种场景下,多条查询SQL必须保证整体的读一致性,

否则,在前条SQL查询之后,后条SQL查询之前,数据被其他用户改变,则该次整体的统计查询将会出现读数据不一致的状态,此时,应该启用事务支持read-only="true"表示该事务为只读事务,比如上面说的多条查询的这种情况可以使用只读事务, 由于只读事务不存在数据的修改,因此数据库将会为只读事务提供一些优化手段,例如Oracle对于只读事务,不启动回滚段,不记录回滚log。 (1)在JDBC中,指定只读事务的办法为:connection.setReadOnly(true); (2)在Hibernate中,指定只读事务的办法为: session.setFlushMode(FlushMode.NEVER);此时,Hibernate也会为只读事务提供Session方面的一些优化手段 (3)在Spring的Hibernate封装中,指定只读事务的办法为: bean配置文件中,prop属性增加“read-Only” 或者用注解方式@Transactional(readOnly=true) Spring中设置只读事务是利用上面两种方式(根据实际情况) 在将事务设置成只读后,相当于将数据库设置成只读数据库,此时若要进行写的操作,会出现错误。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Vue-upload-component Test</title> <script src="https://unpkg.com/vue"></script> <script src="https://unpkg.com/vue-upload-component"></script> </head> <body> <div id="app"> <ul> <li v-for="file in files">{{file.name}} - Error: {{file.error}}, Success: {{file.success}}</li> </ul> <file-upload ref="upload" v-model="files" post-action="/post.method" put-action="/put.method" @input-file="inputFile" @input-filter="inputFilter" > Upload file </file-upload> <button v-show="!$refs.upload || !$refs.upload.active" @click.prevent="$refs.upload.active = true" type="button">Start upload</button> <button v-show="$refs.upload && $refs.upload.active" @click.prevent="$refs.upload.active = false" type="button">Stop upload</button> </div> <script> new Vue({ el: '#app', data: function () { return { files: [] } }, components: { FileUpload: VueUploadComponent }, methods: { /** * Has changed * @param Object|undefined newFile Read only * @param Object|undefined oldFile Read only * @return undefined */ inputFile: function (newFile, oldFile) { if (newFile && oldFile && !newFile.active && oldFile.active) { // Get response data console.log('response', newFile.response) if (newFile.xhr) { // Get the response status code console.log('status', newFile.xhr.status) } } }, /** * Pretreatment * @param Object|undefined newFile Read and write * @param Object|undefined oldFile Read only * @param Function prevent Prevent changing * @return undefined */ inputFilter: function (newFile, oldFile, prevent) { if (newFile && !oldFile) { // Filter non-image file if (!/\.(jpeg|jpe|jpg|gif|png|webp)$/i.test(newFile.name)) { return prevent() } } // Create a blob field newFile.blob = '' let URL = window.URL || window.webkitURL if (URL && URL.createObjectURL) { newFile.blob = URL.createObjectURL(newFile.file) } } } }); </script> </body> </html> 将这个页面改为 vue3 的写法
06-13
好的,下面是将这个页面改为 Vue 3 的写法: ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Vue-upload-component Test</title> <script src="https://unpkg.com/vue@next"></script> <script src="https://unpkg.com/vue-upload-component@3.0.0-beta.6"></script> </head> <body> <div id="app"> <ul> <li v-for="file in files">{{file.name}} - Error: {{file.error}}, Success: {{file.success}}</li> </ul> <file-upload ref="upload" v-model="files" :post-action="'/post.method'" :put-action="'/put.method'" @input-file="inputFile" @input-filter="inputFilter" > Upload file </file-upload> <button v-show="!$refs.upload || !$refs.upload.active" @click.prevent="$refs.upload.active = true" type="button">Start upload</button> <button v-show="$refs.upload && $refs.upload.active" @click.prevent="$refs.upload.active = false" type="button">Stop upload</button> </div> <script> const { createApp, ref } = Vue; const { VueUploadComponent } = vueUploadComponent; createApp({ setup() { const files = ref([]); const inputFile = (newFile, oldFile) => { if (newFile && oldFile && !newFile.active && oldFile.active) { // Get response data console.log('response', newFile.response); if (newFile.xhr) { // Get the response status code console.log('status', newFile.xhr.status); } } }; const inputFilter = (newFile, oldFile, prevent) => { if (newFile && !oldFile) { // Filter non-image file if (!/\.(jpeg|jpe|jpg|gif|png|webp)$/i.test(newFile.name)) { return prevent(); } } // Create a blob field newFile.blob = '' let URL = window.URL || window.webkitURL if (URL && URL.createObjectURL) { newFile.blob = URL.createObjectURL(newFile.file) } }; return { files, inputFile, inputFilter } }, components: { 'file-upload': VueUploadComponent } }).mount('#app'); </script> </body> </html> ``` 主要变化如下: - 使用 `createApp` 创建 Vue 实例; - 使用 `ref` 创建响应式变量; - 使用 `setup` 函数代替 `data` 属性; - 使用 `VueUploadComponent` 替代 `vueUploadComponent`; - 使用 `v-bind` 缩写 `:` 替代 `v-bind`; - 使用 `v-on` 缩写 `@` 替代 `v-on`; - 使用 `file-upload` 替代 `file-upload`。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值