Re: Using transactions in all CRUD operations

Rene Romero Benavides <[email protected]> Wed, 6 Nov 2019 18:53:12 -0600
Newsgroups gmane.comp.db.postgresql.sql
Message-ID <CANaGW0-L83xkmBj14KzPz1FtmPU5h8bbO_gn2KThwmicVku9pA@mail.gmail.com>
--000000000000b2bb160596b717ab
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

The topic you need to research is "repeatable reads", if you read something
within a transaction, depending on the database isolation level, you could
get different results, if you want repeatable reads, you may need to
consider SELECT statements within transactions.

On Wed, Nov 6, 2019 at 6:42 PM JORGE MALDONADO <[email protected]>
wrote:

> Hello,
>
> I am developing an information system applying several design patterns
> being the Unit of Work one of them. For this pattern, my code automatical=
ly
> implements the use of transactions and this means that all of the DB CRUD
> operations will use them: INSERT, UPDATE, DELETE AND SELECT statements. I=
t
> makes sense to me that all of these operations, except for the SELECT
> statement, make use of transactions. However, my Unit of Work design
> pattern has them implemented by default. I have read some articles about
> using transactions on SELECT statements and have seen that it is not as
> absurd as it seems to me to use transactions with only SELECT statements
> inside. My main reason to use transactions in all CRUD operations is to
> maintain my Unit of Work design pattern standard. If using transactions f=
or
> all CRUD operations is not a good practice or not recommendable, then I
> have to choice to re-design my code
>
> I will very much appreciate your valuable feedback on this topic.
>
> Respectfully,
> Jorge Maldonado
>
>
> <https://www.avast.com/sig-email?utm_medium=3Demail&utm_source=3Dlink&utm=
_campaign=3Dsig-email&utm_content=3Dwebmail> Libre
> de virus. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=3Demail&utm_source=3Dlink&utm=
_campaign=3Dsig-email&utm_content=3Dwebmail>
> <#m_2966362734098406000_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>


--=20
El genio es 1% inspiraci=C3=B3n y 99% transpiraci=C3=B3n.
Thomas Alva Edison
http://pglearn.blogspot.mx/

--000000000000b2bb160596b717ab
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">The topic you need to research is &quot;repeatable reads&q=
uot;, if you read something within a transaction, depending on the database=
 isolation level, you could get different results, if you want repeatable r=
eads, you may need to consider SELECT statements within transactions.=C2=A0=
</div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">=
On Wed, Nov 6, 2019 at 6:42 PM JORGE MALDONADO &lt;<a href=3D"mailto:jorgem=
[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquot=
e class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px s=
olid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div>Hello,</div><=
div><br></div><div>I am developing=C2=A0an information system applying seve=
ral=C2=A0design patterns being the Unit of Work one of them. For this patte=
rn, my code automatically implements the use of transactions and this means=
 that all of the DB CRUD operations will use them: INSERT, UPDATE, DELETE A=
ND SELECT statements. It makes sense to me that all of these operations, ex=
cept for the SELECT statement, make use of transactions. However, my Unit o=
f Work design pattern has them implemented by default. I have read some art=
icles about using transactions on SELECT statements and have seen that it i=
s not as absurd as it seems to me to use transactions with only SELECT stat=
ements inside. My main reason to use transactions in all CRUD operations is=
 to maintain my Unit of Work design pattern standard. If using transactions=
 for all CRUD operations is not a good practice or not recommendable, then =
I have to choice to re-design my code</div><div><br></div><div>I will very =
much appreciate your valuable feedback on this=C2=A0topic.</div><div><br></=
div><div>Respectfully,</div><div>Jorge Maldonado</div></div><div id=3D"gmai=
l-m_2966362734098406000DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br> <table st=
yle=3D"border-top:1px solid rgb(211,212,222)">
	<tbody><tr>
      <td style=3D"width:55px;padding-top:18px"><a href=3D"https://www.avas=
t.com/sig-email?utm_medium=3Demail&amp;utm_source=3Dlink&amp;utm_campaign=
=3Dsig-email&amp;utm_content=3Dwebmail" target=3D"_blank"><img src=3D"https=
://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-n=
o-repeat-v1.gif" alt=3D"" width=3D"46" height=3D"29" style=3D"width: 46px; =
height: 29px;"></a></td>
		<td style=3D"width:470px;padding-top:17px;color:rgb(65,66,78);font-size:1=
3px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Libre de virus=
. <a href=3D"https://www.avast.com/sig-email?utm_medium=3Demail&amp;utm_sou=
rce=3Dlink&amp;utm_campaign=3Dsig-email&amp;utm_content=3Dwebmail" style=3D=
"color:rgb(68,83,234)" target=3D"_blank">www.avast.com</a> 		</td>
	</tr>
</tbody></table>
<a href=3D"#m_2966362734098406000_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" wid=
th=3D"1" height=3D"1"></a></div>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature">El genio es 1% inspiraci=C3=B3n y 99% transpirac=
i=C3=B3n.<br>Thomas Alva Edison<br><a href=3D"http://pglearn.blogspot.mx/" =
target=3D"_blank">http://pglearn.blogspot.mx/</a><br><div style=3D"padding:=
0px;margin-left:0px;margin-top:0px;overflow:hidden;color:black;font-size:10=
px;text-align:left;line-height:130%"></div><div><br></div></div>

--000000000000b2bb160596b717ab--