
252 Cal.App.2d 185 (1967)
LEMUEL F. SYLVESTER, JR., et al., Plaintiffs and Appellants,
v.
LEONARD P. SOULSBURG et al., Defendants and Respondents.
Civ. No. 712. 
California Court of Appeals. Fifth Dist.  
June 29, 1967.
 Kenneth M. Smith and Claude L. Welch for Plaintiffs and Appellants.
 Chain & Younger and Dustin N. Jameson for Defendants and Respondents.
 CONLEY, P. J.
 The plaintiffs, Lemuel F. Sylvester, Jr., and his wife, Thetis L. Sylvester, appeal from a judgment of dismissal granted in Kern County case No. 87180 on the ground that recovery was barred by collateral estoppel. In a prior action (Kern County No. 86796), filed June 18, 1963, the Soulsburgs had sued the Sylvesters to terminate a contract for the purchase of real and personal property; that suit prayed for possession of, and to quiet title to, the realty, and for the value of the use of the property if the Sylvesters should retain possession after the filing of the suit; in a second cause of action, the plaintiffs therein sought to foreclose the chattel mortgage given as security for the performance of the purchase contract and prayed for a deficiency *187 judgment; request was also made for attorneys' fees and costs. In their answer in that case (No. 86796), the Sylvesters denied that they were in default, alleged that the purchase contract had been induced by the fraud of the Soulsburgs, and averred that the Soulsburgs had illegally trespassed upon the premises while the purchase contract was in full force and effect and had attempted to dispossess defendants by removing part of the equipment, which made it impossible for the purchasers to perform their contract; the Sylvesters further claimed in their answer that they owed nothing by reason of the chattel mortgage, because the Soulsburgs had damaged them by unlawfully entering upon the land during the existence of the contract and had wrongfully taken possession of the personal property and had removed some of the items covered by the chattel mortgage.
 On August 6, 1963, the Sylvesters filed the complaint in the present suit (No. 87180) asking for damages for trespass to the same real and personal property and, in a second count, damages for conspiracy to trespass. The Sylvesters alleged that the Soulsburgs personally and by their agents, unlawfully trespassed upon the premises, barred the Sylvesters from their home located thereupon and prevented the use of the realty by placing guards around the house, substituting locks upon various buildings, and removing personal property of the plaintiffs; it was claimed that the defendants entered the plaintiffs' home, took possession of papers and documents, and prevented plaintiffs from carrying on their ordinary activities; the Sylvesters asked $35,000 general and special damages and $10,000 exemplary damages.
 The answer of the Soulsburgs to the instant case (No. 87180) was filed February 4, 1964; it denied the allegations of the complaint, alleged that their entry on the premises was by consent, and in accordance with a privilege so to do contained in a written security transaction as to which plaintiffs were in default. After the ending of the first suit as hereinafter alleged, the Soulsburgs were granted leave to file a supplemental answer in the present action by which they alleged that the dismissal with prejudice of the prior action (No. 86796), together with the execution and delivery by the Sylvesters of a quitclaim deed of the real property and a bill of sale of the personalty, operated as a full settlement, compromise, release and retraxit of all claims as between the parties and prevented the further prosecution of the instant case by the Sylvesters; section 439 of the Code of Civil Procedure *188 was specifically cited as a bar; the foregoing amendment referred to a stipulated judgment of dismissal with prejudice of the first action (No. 86796). At the same time, a quitclaim deed was given by the Sylvesters to the Soulsburgs and all personal property turned back to them.
 The instant case came on for trial, and, after a full hearing of the motion to dismiss, the trial judge, referring particularly to Flickinger v. Swedlow Engineering Co., 45 Cal.2d 388 [289 P.2d 214]; and Saunders v. New Capital for Small Businesses, Inc., 231 Cal.App.2d 324 [41 Cal.Rptr. 703], stated that, under the doctrine of collateral estoppel, the motion for dismissal as to the Soulsburgs would be granted. The attorneys for the respective parties then entered into a stipulation that the two Smiths and Conrad Neal, who were the remaining three defendants, were, in fact, agents of the Soulsburgs. Prior thereto, the attorney for the plaintiffs had dismissed the action as to all defendants other than the Soulsburgs, the Smiths, and Conrad Neal; the court, based upon the stipulation above mentioned, then granted the motion for dismissal also as to the Smiths and Neal.
 In Bernhard v. Bank of America, 19 Cal.2d 807, 813 [122 P.2d 892], the criteria required to determine the validity of a plea of res judicata (applicable equally to a plea of collateral estoppel as held in Saunders v. New Capital for Small Businesses, Inc., supra, 231 Cal.App.2d 324, 331- 332), are discussed as follows: "In determining the validity of a plea of res judicata three questions are pertinent: Was the issue decided in the prior adjudication identical with the one presented in the action in question? Was there a final judgment on the merits? Was the party against whom the plea is asserted a party or in privity with a party to the prior adjudication?"
 The plaintiffs in the present case were defendants in the former case, and it is, therefore, clear that the party against whom the plea is asserted was a party to the prior adjudication. The inquiry as to whether there was a "final judgment on the merits" in the earlier case is answered by the holding that a stipulated judgment of dismissal in connection with which consideration is given is equivalent as between the parties to a final judgment on the merits. In Datta v. Staab, 173 Cal.App.2d 613, 620-621 [343 P.2d 977], it is said:
 "Appellant asserts that a voluntary dismissal has only the effect of a withdrawal of the plaintiff's claim; that it leaves the defendant as though he had never been a party. This is *189 undoubtedly true where plaintiff has received nothing in return for the dismissal. (Cook v. Stewart McKee & Co., 68 Cal.App.2d 758 [157 P.2d 868]; McDougald v. Hulet, 132 Cal. 154 [64 P. 278]; Collins v. Ramish, 182 Cal. 360 [188 P. 550].) The effect of a dismissal with prejudice is quite different, however, when it is executed and filed in return for a consideration moving from the defendant. Such a dismissal operates as a complete bar to any future action (Markwell v. Swift & Co., 126 Cal.App.2d 245 [272 P.2d 47]), and has the same legal effect as a common law retraxit. (Ghiringhelli v. Riboni, 95 Cal.App.2d 503, 506 [213 P.2d 17]; Goddard v. Security Title Ins. & Guar. Co., 14 Cal.2d 47 [92 P.2d 804].) 'A retraxit is equivalent to a verdict and judgment on the merits of the case and is deemed to be a bar to another suit for the same cause between the same parties. ... Where the parties to an action settle their dispute and agree to a dismissal, it is a retraxit and amounts to a decision on the merits and as such is a bar to further litigation on the same subject matter between the parties.' (17 Am.Jur. 162, 163; see also 16 Cal.Jur.2d 146.) We accordingly hold, that in this state a dismissal after issues are joined, executed in return for a consideration moving from the defendant and which is to operate as a retraxit, is not only res judicata as to the claims of the plaintiff but as a result of the provisions of Code of Civil Procedure, section 439, it operates also as a collateral estoppel--a bar to any claim which defendant could have asserted in said action as a counterclaim arising out of the same transaction. Since it is within the exclusive power of the defendant to bring about such result by the settlement of plaintiff's claim, such a rule would appear to be just and in harmony with the objectives of the statute in question."
 "Thus, so far as the instant action is concerned, the judgment of dismissal in action Number 458457, Staab v. Datta, is res judicata not only as to the claim asserted by Staab against Datta in said action, but as a result of the compensation paid by Datta to Staab in return for said dismissal, it is also a bar to the claim of Datta asserted against Staab and Abbot Hanks, Inc., his employer, in action Number 461881 (see 29 Cal.Jur.2d, 252)." (See also Rothtrock v. Ohio Farmers Ins. Co., 233 Cal.App.2d 616 [43 Cal.Rptr. 716]; Ghiringhelli v. Riboni, 95 Cal.App.2d 503, 506 [213 P.2d 17].)
 In answer to the question above cited in the Bernhard case "Was the issue decided in the prior adjudication identical with the one presented in the action in question?"--as we *190 are dealing with collateral estoppel rather than res judicata in the primary sense, we must turn to section 439 of the Code of Civil Procedure, which reads as follows:
 "If the defendant omits to set up a counterclaim upon a cause arising out of the transaction set forth in the complaint as the foundation of the plaintiff's claim, neither he nor his assignee can afterwards maintain an action against the plaintiff therefor."
 Section 437 of the Code of Civil Procedure provides that a defendant's answer shall contain:
 "1. A general or specific denial of the material allegations of the complaint controverted by the defendant."
 "2. A statement of any new matter constituting a defense or counterclaim."
 And section 438 of the Code of Civil Procedure provides:
 "The counterclaim mentioned in section 437 must tend to diminish or defeat the plaintiff's recovery and must exist in favor of a defendant and against a plaintiff between whom a several judgment might be had in the action; ..."
 Unquestionably, the Sylvesters could have set up a counterclaim in the suit brought by the Soulsburgs. The Soulsburgs had asked, among other things, for a judgment in money damages, and what the Sylvesters could have included in a counterclaim for damages by reason of the alleged improper actions of the Soulsburgs would have constituted new material which would have tended to cut down the damages sought by the Soulsburgs in their complaint.
 Did the subject matter of the potential counterclaim arise from the same "transaction" which formed the basis of the complaint?
 [1] Section 439 of the Code of Civil Procedure bars a subsequent action only when the counterclaim meets the essential elements set forth in section 438 (that is, it must tend to diminish or defeat the plaintiffs' recovery and must exist in favor of a defendant and against a plaintiff between whom a several judgment might be had in the action), and when it arises from the same transaction.
 In Carey v. Cusack, 245 Cal.App.2d 57, 66 [54 Cal.Rptr. 244], it is said: "The purpose of section 439 is to provide for the settlement in a single action of all conflicting claims between the parties arising out of the same transaction and thus avoid multiplicity of actions and judgments. To achieve this purpose, the statute has been liberally construed. The term 'transaction' is not limited to a single, isolated act or *191 occurrence, but may embrace a series of acts or occurrences logically interrelated (Saunders v. New Capital for Small Businesses, Inc., supra, pp. 334-336.)"
 It is contended by the appellants that the potential counterclaim which could have been urged by the present appellants in the first case would not have been sufficient, under section 439 of the Code of Civil Procedure, because the complaint in the first case was based on contract, and the counterclaim, if any, would have been based on tort, and, also, in somewhat similar vein, that the plaintiffs in the first case were acting in the capacity of a person claiming under contract, and the potential counterclaimants would have been acting in the capacity of a person injured by tort. This attempted distinction is not sound. [2] As is said in 2 Witkin, California Procedure, Pleading (1954) section 580, at page 1591: "The complaint may be in contract and the counterclaim in tort, or vice versa. (Luse v. Peters (1933) 219 Cal. 625, 631 [28 P.2d 357] [complaint for price of goods sold, counterclaim for damages for fraud]; Kittle Mfg. Co. v. Davis (1935) 8 Cal.App.2d 504, 513 [47 P.2d 1089].)"
 There are many cases which apply section 439 of the Code of Civil Procedure, which involve both contract and tort. For example, in Black v. Dillon, 213 Cal.App.2d 295 [28 Cal.Rptr. 678], where a patient sued a doctor for malpractice, it is held that section 439 of the Code of Civil Procedure prevented recovery by the doctor for his professional fees charged to defendant for services performed for her personally, as he should have claimed them by counterclaim in the malpractice action. And in Baker v. Eilers Music Co., 175 Cal. 652 [166 P. 1006], it is pointed out that in an action on a note given for rental, the defendant should plead by counterclaim that he was entitled to damages for his eviction, and that he could not later bring suit independently for such alleged damages; in other words, it was requisite that the defendant in the action on the note should claim damages for the eviction in the same litigation, thus, combining a hearing of the tort claim with an opposing contract claim in order to warrant recovery.
 The word "transaction" embraces almost any activity by a person which affects another's right and out of which a cause of action may arise. (See 44 Cal.Jur.2d, Setoff and Counterclaim,  34, pp. 817-818; Baker v. Eilers Music Co., supra, 175 Cal. 652; Black v. Dillon, supra, 213 Cal.App.2d 295; Saunders v. New Capital for Small Businesses, Inc., supra, 231 Cal.App.2d 324; Flickinger v. Swedlow Engineering Co., *192 supra, 45 Cal.2d 388; Brunswig Drug Co. v. Springer, 55 Cal.App.2d 444, 451 [130 P.2d 758]; Kittle Mfg. Co. v. Speer, 3 Cal.App.2d 148 [39 P.2d 278].) (See also Nevada Land & Inv. Corp. v. Sistrunk, 220 Cal. 174 [30 P.2d 389].)
 [3] The claim of damage for trespass arose out of a series of acts on the part of the Soulsburgs closely related to the subject matter and claims in the first action (No. 86796); the common subject matter was the real and personal property and the contracts by which it had been sold to the Sylvesters; upon alleged default of payment under the contracts for the sale of the realty, the Soulsburgs began the action to recover possession of the land and to foreclose the chattel mortgage; they asked for damages, entered upon the real property, took possession of the personal property, and for a time remained in possession; all these acts were in continuous sequence and made up in their entirety a single "transaction," as the term is used in section 439 of the Code of Civil Procedure. The claims urged by the Sylvesters were based on the same land, the same personalty, and the same contracts; the Sylvesters should have asserted their demands by counterclaim in their answer in the first case (No. 86796); by failing to do so, they lost the right to sue separately in a later action.
 Appellants' argument that the capacity in which the Soulsburgs and the Sylvesters would have prosecuted the original suit and a counterclaim, if it had been filed, would not have been the same, may be based on the wording in 2 Witkin, California Procedure (1954) section 582, page 1593, where it is said: "Where a single plaintiff sues a single defendant on a several claim, the requirement is fully met if the counterclaim is held by the defendant in the same capacity as he owes the obligation to the plaintiff. But if the claims are held in different capacities the counterclaim may be bad. Thus, a defendant sued as a trustee cannot set off claims owed to him personally. (Garrison v. Brown & Sons (1944) 25 Cal.2d 473, 476 [154 P.2d 377]; 28 Cal.2d 28 [168 P.2d 153] [later decision in the same case]; see 10 So.Cal.L.Rev. 426; Clark, p. 671.)"
 The quotation means only that a litigant cannot confuse his personal rights with his rights as a trustee. Each of the major parties in the litigation would have been acting in his own right throughout if a counterclaim had been filed, and not in different capacities.
 The wording and meaning of section 439 of the Code of Civil Procedure seem perfectly clear. We cannot read that section in any other way than our previous discussion indicates. *193 The whole case turns on the meaning of "transaction" as used in the code section. [4] We think that, where there is an action on a contract for the sale of land and the personal property used on it, with the purchaser in possession, and there exists a claim by the purchaser that he has been wronged by the seller in not complying with the terms of the contract, the whole controversy and all its parts relate collectively to a single "transaction," and that the public policy enunciated in section 439 of the Code of Civil Procedure requires that all of the phases of the relationship should be resolved in a single litigation, or be forever barred.
 [5] Code of Civil Procedure section 439 extends the application of the doctrine of collateral estoppel beyond "issues actually litigated" in a former action; it applies also to a judgment of dismissal with prejudice where there has been consideration and to all claims arising out of the same transaction which could have been asserted as a counterclaim. (Datta v. Staab, supra, 173 Cal.App.2d 613, 620-621; Saunders v. New Capital for Small Businesses, Inc., supra, 231 Cal.App.2d 324, 334; Great Western Furniture Co. v. Porter Corp., 238 Cal.App.2d 502, 512-514 [48 Cal.Rptr. 76]; Witkin, Cal. Procedure, 1965 Supp. pp. 527-528; 2 A.L.R.2d 546, 548.)
 The judgment is affirmed.
 Stone, J., and Gargano, J., concurred.
