
68 Cal.App.3d 621 (1977)
137 Cal. Rptr. 681
CHARLES BARRIOS GONZALES et al., Plaintiffs and Appellants,
v.
THE STATE OF CALIFORNIA, Defendant and Respondent.
Docket No. 37800.
Court of Appeals of California, First District, Division One.
March 30, 1977.
*626 COUNSEL
Leslie C. Nichols, Rubin Tepper, Mayron & Emanuel, Mayron, Emanuel & Ince and Michael Allan Mayron for Plaintiffs and Appellants.
Evelle J. Younger, Attorney General, and Robert L. Bergman, Assistant Attorney General, and J.L. Henderson, Deputy Attorney General, for Defendant and Respondent.
OPINION
MOLINARI, P.J.
Plaintiffs appeal from an order granting their ex parte motion to dismiss their action pursuant to Code of Civil Procedure section 581[1] following the sustaining of defendant's demurrer to plaintiffs' amended complaint with leave to amend.
The action is a class action brought by plaintiffs on behalf of themselves and others similarly situated who have or will have their convictions under Vehicle Code section 23102, subdivision (a), (misdemeanor drunk driving) declared unconstitutional, seeking to establish and enforce a constructive trust naming defendant (State of California) trustee of money paid to the state pursuant to said convictions, alleging that defendant is wrongfully withholding their money, and seeking to impose a constructive trust in order to prevent unjust enrichment.
A demurrer to the complaint was interposed by defendant on several grounds. The demurrer was sustained on the ground that it failed to allege compliance with the presentation of claims against the state as provided for in Government Code section 905.2. Plaintiffs amended their complaint alleging compliance with Government Code section 905.2. Defendant demurred to the amended complaint on substantially the same grounds urged in its demurrer to the original complaint. The grounds of the demurrer set forth were (1) that plaintiffs have not properly complied with the claims filing provisions of the California Government Code; (2) that the state is immune; (3) that a finding that a prior conviction is constitutionally invalid does not require a refund of the fines and penalty assessments; (4) that there is a misjoinder of parties *627 in that the allegations of the complaint do not establish facts necessary to constitute a class action; and (5) that the complaint is uncertain in that it does not make clear whether the convictions that have been and will be declared unconstitutional were or will be declared unconstitutional on appeal or on the basis of collateral attack, and in that it fails to set forth when the alleged causes of action arose, when the setting aside of previous convictions occurred, or when the filing of the claim with the State Board of Control was made. The demurrer was sustained, with leave to amend, on all the grounds set forth in the demurrer. Plaintiffs chose to stand on the amended complaint.
(1) Plaintiffs first contend that the trial court, having sustained the demurrer to the original complaint on only one ground, erred in sustaining the demurrer to the amended complaint on grounds identical to those raised by the first demurrer. They contend that the trial court impliedly overruled all grounds of the first demurrer which it did not specifically sustain and that, therefore, defendant was estopped from relitigating the issues already determined.
Reliance is placed by plaintiffs on section 472d of the Code of Civil Procedure which provides: "Whenever a demurrer in any action or proceeding is sustained, the court shall include in its decision or order a statement of the specific ground or grounds upon which the decision or order is based which may be by reference to appropriate pages and paragraphs of the demurrer." This section has been interpreted, however, to require affirmance of trial court's rulings on demurrers if any of the grounds raised by the defendant require the sustaining of the demurrer, whether or not the court specifies all the grounds. (Banerian v. O'Malley, 42 Cal. App.3d 604, 610 [116 Cal. Rptr. 919].) Accordingly, if any ground stated in a demurrer is sustainable, the trial court's action is proper. The court need not consider all the points raised in the demurrer. "`It is the validity of the court's action in sustaining the demurrer which is here reviewable, and not the court's opinion or statement of reasons for its action.'" (Weinstock v. Eissler, 224 Cal. App.2d 212, 225 [36 Cal. Rptr. 537]; italics added.) No contention is made that the court improperly sustained the demurrer to the original complaint on the one specific ground stated in its order sustaining the demurrer thereto.
Adverting to the amended complaint we perceive it as one purporting to state a cause of action based on implied contract where the mutual obligations of the parties are implied by their conduct. (Civ. Code, § 1621.) (2) "The doctrine of implied contracts has its foundation in *628 the doctrine of unjust enrichment. [Citation.]" (McCaffrey v. Cronin, 140 Cal. App.2d 528, 535 [295 P.2d 587].) (3) Accordingly, where a person who holds title to property is subject to an equitable duty to convey it to another on the ground that he would be unjustly enriched if he were permitted to retain it, a constructive trust arises. (Rest., Restitution, § 160.)
(4) The doctrine of unjust enrichment is applied in cases where a party is entitled to restoration of benefits lost by virtue of an erroneous judgment. Thus, it is the rule that upon reversal of an action a court has power to restore benefits upon the rationale that a reversal of the judgment places the action in the posture as though it had never been tried. In such a situation the court will, where justice requires it, place the parties as nearly as may be possible in the condition in which they stood previously. (Schubert v. Bates, 30 Cal.2d 785, 790 [185 P.2d 793]; Ward v. Sherman, 155 Cal. 287, 291 [100 P. 864]; Holmes v. Williams, 127 Cal. App.2d 377 [273 P.2d 931]; see Code Civ. Proc., § 908.)
In California, as applied to criminal cases, it is specifically provided by statute that fines are to be returned to the defendant if the judgment is reversed and the case is dismissed or if the appellate court directs a final disposition of the action in the defendant's favor. (Pen. Code, § 1262.[2])
(5) Defendant's characterization of the action as one in tort so as to bring it within the provisions of the public entity tort claims statutes (Gov. Code, § 810 et seq.) is inaccurate. Nothing in those statutes affects liability based on contract or the right to obtain relief other than money or damages against a public entity or public employee. (Gov. Code, § 814; National Automobile & Cas. Ins. Co. v. Pitchess, 35 Cal. App.3d 62, 64-65 [110 Cal. Rptr. 649]; Wiechmann Engineers v. State of California ex rel. Dept. Pub. Wks., 31 Cal. App.3d 741, 749-752 [107 Cal. Rptr. 529]; Western Title Guar. Co. v. Sacramento & San Joaquin Drainage Dist., 235 Cal. App.2d 815, 820 [45 Cal. Rptr. 578]; see Minsky v. City of Los Angeles, 11 Cal.3d 113, 121 [113 Cal. Rptr. 102, 520 P.2d 726].) In Minsky it was held that a claim for specific recovery of property has never been considered a claim for "money or damages" as used in Government Code section 905, providing for the required presentation of claims against local public entities, or its predecessors. (At p. 121.) Accordingly, *629 it is concluded that defendant's general demurrer on the grounds that the state is immune and that plaintiffs have not properly complied with the claims filing provisions of the Government Code, was not well taken and should have been overruled on these grounds.
(6) Adverting to the ground of demurrer that there is a misjoinder of parties in that the allegations of the complaint do not establish facts necessary to constitute a class action, we conclude that the demurrer was properly sustained on this ground on the basis that there is not a cognizable and manageable class of plaintiffs and that the utilization of a class action suit will not serve the ends of justice. (See Vasquez v. Superior Court, 4 Cal.3d 800 [94 Cal. Rptr. 796, 484 P.2d 964]; Daar v. Yellow Cab Co., 67 Cal.2d 695 [63 Cal. Rptr. 724, 433 P.2d 732].) We observe that the complaint not only seeks to encompass convictions that have been declared unconstitutionally invalid but also all those that in the future may fit into this category.
In Bacom v. County of Merced, 66 Cal. App.3d 45 [136 Cal. Rptr. 14],[3] the reviewing court affirmed the dismissal of an action against a county, its auditor and the State of California and its Controller brought as a class action to recover a return of fines paid on misdemeanor convictions subsequently set aside on constitutional grounds. In Bacom the misdemeanor convictions had occurred in the year immediately preceding May 16, 1974, and they had been vacated on direct attack. The reviewing court held that the class action could not be maintained due to unmanageability of the class and the creation of burdens on the entire judicial system outweighing any benefits of the class action. (At pp. 48-49.) The court noted that during the year concerned more than 14,000 convictions for drunk driving alone had been vacated, that there were 300 jurisdictions empowered to vacate judgments of convictions in misdemeanor cases, and observed that should the plaintiff and his class prevail the repayment of the fines and assessments would cause serious problems to the various public agencies to which the monies had been distributed. (At pp. 49-51.)
The demurrer in Bacom was interposed on several grounds including the ground that the complaint did not state facts necessary to state a class action. The sustaining of the demurrer without leave to amend was upheld by the appellate court on this ground. (66 Cal. App.3d 45, 52.)
*630 We agree with the rationale of Bacom. The facts alleged in the instant complaint, encompassing a far greater number of plaintiffs than those in Bacom and purporting to include plaintiffs who may be similarly situated in the future, rather than those whose claims fall within a specified period as in Bacom, clearly present a situation involving an unmanageable class and one that can create more problems than it can solve. The type of class action pleaded in the present case is not one the maintenance of which will be of substantial benefit to both the litigants and the courts. Under these circumstances a class action is inappropriate. (See Blue Chip Stamps v. Superior Court, 18 Cal.3d 381, 385 [134 Cal. Rptr. 393, 556 P.2d 755]; City of San Jose v. Superior Court, 12 Cal.3d 447, 459 [115 Cal. Rptr. 797, 525 P.2d 701].) Accordingly, because a manageable class has not been defined the demurrer on the misjoinder ground was properly sustained.
We are thus left with a consideration of the allegations of the complaint insofar as they concern the individually named plaintiffs who have purported to bring the action on behalf of themselves as well as those asserted to be similarly situated. These plaintiffs allege that they are individual members of the alleged class and that their interests are affected in the same manner as the interests of all members of said class are affected. As respect themselves, these plaintiffs allege that they were convicted of a violation of California Vehicle Code section 23102; that as part of the sentences imposed they were ordered to pay a fine or penalty or fine and penalty; that subsequent to the date of their conviction courts in this state have declared their convictions unconstitutional and void; that defendant has retained and continue to retain monies paid by said plaintiffs as a fine or penalty or a fine and penalty; and that defendant has no lawful claim to said money.
(7) Our inquiry is whether the allegations of the individually named plaintiffs state a cause of action. The thrust of defendant's general demurrer is that the finding that a prior conviction is unconstitutionally invalid does not require a refund of the fines and penalty assessments.
In Colvig v. RKO General, Inc., 232 Cal. App.2d 56, 65-66 [42 Cal. Rptr. 473], we reiterated the principles defining a cause of action as follows: "The essence of a cause of action is the existence of a primary right and one violation of that right, i.e., it arises out of an antecedent primary right and corresponding duty, and a breach of such primary right and duty by the person upon whom the duty rests. [Citations.] The primary right and duty and the delict or wrong constitute the cause of action in *631 the legal sense. [Citations.] `The cause of action is simply the obligation sought to be enforced.' [Citations.] All that is necessary as against a general demurrer is that, upon a consideration of all the facts stated, it appears the plaintiff is entitled to any relief at the hands of the court against the defendant, notwithstanding the facts may not be clearly stated, or may be intermingled with a statement of other facts irrelevant to the cause of action shown or although the plaintiff may demand relief to which he is not entitled under the facts alleged. [Citation.]"
We are of the opinion that in the light of these principles the complaint of the individually named plaintiffs states a cause of action. It alleges a classic case of a cause of action for restitution. The complaint alleges a primary right in these plaintiffs that they be restored the fines and penalties assessed upon their conviction of the specified misdemeanor because the conviction has been found to be void by a court. On the part of defendant the complaint alleges that there is a corresponding duty on its part to return such fines and penalties and that by failing in their duty it has breached plaintiffs' antecedent primary right. As we have pointed out above, where a criminal conviction is set aside with the effect of finally disposing of the action, the defendant is entitled to a return of any fine imposed and there is a duty upon the public entity to which the fine was paid to return the fine on the basis that the retention of such monies will result in unjust enrichment. In such case the law creates an obligation because one who obtains a benefit which he may not justly retain is unjustly enriched. (See Branche v. Hetzel, 241 Cal. App.2d 801, 807 [51 Cal. Rptr. 188].)[4]
(8) Adverting to the special demurrer we first take cognizance of certain applicable principles: "A demurrer for uncertainty will not lie where the ambiguous facts alleged are presumptively within the knowledge of the demurring party. [Citations.] A special demurrer should not be sustained if the allegations are sufficiently clear to apprise the defendant of the issues that must be met, even if the allegations of the complaint may not be as clear and as detailed as might be desired. [Citations.] ... [a] demurrer for uncertainty will not lie as to even uncertain and ambiguous allegations, if such allegations refer to immaterial matters. In such event, they will be treated as surplusage and disregarded. [Citations.]" (Merlino v. West Coast Macaroni Mfg. Co., 90 Cal. App.2d 106, 108 [202 P.2d 748].)
*632 (9a) As a ground of special demurrer for uncertainty defendant alleged that the complaint does not make it clear whether the convictions that have been declared unconstitutional were declared unconstitutional on appeal or on the basis of collateral attack. In considering this ground we note that the complaint does not merely allege that the convictions were declared unconstitutional but alleges also that they were declared unconstitutional and void. Defendant seeks clarity on the basis that if the complaint discloses that the convictions were declared constitutionally invalid as the result of a collateral attack plaintiffs cannot state a cause of action.
In view of defendant's contention we deem it expedient to point out the distinction between a direct and a collateral attack on a judgment. (10) A direct attack is a proceeding instituted for the specific purpose of vacating, reversing, or otherwise attacking the judgment as by motion for new trial, motion to vacate, appeal, an independent action in equity, and by certiorari or other writs. (5 Witkin, Cal. Procedure (2d ed. 1971) pp. 3584-3585; see Palmquist v. Palmquist, 212 Cal. App.2d 340, 344 [27 Cal. Rptr. 756]; People ex rel. Mosk v. City of Santa Barbara, 192 Cal. App.2d 342, 356 [13 Cal. Rptr. 423].) (11) A collateral attack is made, not in a proceeding brought for the specific purpose of attacking the judgment, but in some other proceeding having a different purpose  it is an attempt to avoid the effect of a judgment or order made in some other proceeding. (5 Witkin, Cal. Procedure (2d ed. 1971) p. 3587; see Palmquist v. Palmquist, supra, 212 Cal. App.2d 340, 344.) In a collateral attack the invalidity of the former judgment or order must appear on the face of the record and if such invalidity or want of jurisdiction does not appear on the face of the record, it will be presumed in favor of the former judgment or order. (Estate of Keet, 15 Cal.2d 328, 333 [100 P.2d 1045]; Rico v. Nasser Bros. Realty Co., 58 Cal. App.2d 878, 882 [137 P.2d 861]; McAllister v. Superior Court, 28 Cal. App.2d 160, 162 [82 P.2d 462].) As observed by Witkin "In a direct attack the judgment is reviewed for error, including jurisdictional defects. In a collateral attack the judgment comes up only incidentally, and may be effectively challenged only if it is completely invalid as to require no ordinary review to annul it." (5 Witkin, Cal. Procedure (2d ed. 1971), supra, at p. 3587.)
Defendant, in its arguments, has assumed that the basis of plaintiffs' claim of constitutional invalidity is predicated on the striking of an alleged prior conviction for misdemeanor drunk driving from the accusatory pleading in a pending criminal proceeding and thus urge that *633 a collateral attack resulting in such an order does not have the effect of wiping out the prior judgment of conviction. It relies on People v. Burke, 47 Cal.2d 45 [301 P.2d 241], and Gonzalez v. Municipal Court, 32 Cal. App.3d 706 [108 Cal. Rptr. 612]. These cases hold that the striking or dismissal of a charge of prior conviction is not the equivalent of a determination that the defendant did not in fact suffer the conviction but merely prevents the constitutionally invalid prior conviction from being used to enhance the punishment that may be imposed in the pending criminal proceeding or to increase the severity of administrative sanctions. (People v. Burke, supra, at p. 51; Gonzalez v. Municipal Court, supra, at pp. 711-712.)
We are unable to ascertain from the complaint whether the individual plaintiffs predicate their cause of action upon constitutional invalidity pursuant to the type of collateral proceeding initiated in Burke and Gonzalez. We do note, however, that Gonzalez points out the distinction between a direct and a collateral attack upon a prior judgment of conviction. Thus it is pointed out that there is a distinction between an attack on a conviction on constitutional grounds by way of a motion to strike allegations of prior convictions from an accusatory pleading in a pending criminal proceeding and that pursuant to a motion to vacate a prior judgment of conviction which must be initiated by the defendant in the action in which the prior judgment was rendered. (Gonzalez v. Municipal Court, supra, 32 Cal. App.3d 706, 710, 712; see Thomas v. Department of Motor Vehicles, 3 Cal.3d 335, 338 [90 Cal. Rptr. 586, 475 P.2d 858].)
Gonzalez points out that a defendant must continue to fulfill the conditions of the sentence imposed upon him as a result of the prior conviction unless he successfully moves to vacate or set aside the judgment in the original action, in which event he may be subject to retrial, notwithstanding that the prior conviction is declared constitutionally invalid in a pending criminal proceeding. (32 Cal. App.3d at p. 712, fn. 11.) The analysis is in keeping with the distinction between a direct and a collateral attack pointed out above.
(12) We perceive that although a conviction may be collaterally attacked on constitutional grounds in order to avoid the effect of the judgment of conviction in a pending proceeding, such avoidance does not have the effect of wiping out the prior judgment of conviction. Such a result may only be achieved upon direct attack. Accordingly, in order to set aside a judgment imposing a fine the underlying conviction upon *634 which such judgment rests must be vacated and set aside by the court in which the prior conviction was obtained and the fine imposed.
It should be noted that a proceeding to set aside or vacate a prior judgment of conviction, if successful, subjects a defendant to a retrial. (Gonzalez v. Municipal Court, supra, 32 Cal. App.3d 706, 712.) Therefore, although a court is empowered collaterally to determine the constitutional validity of prior convictions sustained in another jurisdiction (People v. Coffey, 67 Cal.2d 204, 215 [60 Cal. Rptr. 457, 430 P.2d 15]), that court has no jurisdiction to vacate or set aside a judgment of conviction and order a retrial in an action prosecuted in the court of another judicial district. (Gonzalez v. Municipal Court, supra, at p. 712, fn. 11.)
(9b) We conclude, therefore, that in order for the individual plaintiffs to state a cause of action it was incumbent upon them to plead that the prior convictions in the instant case were vacated or set aside in the court in which the prior conviction was obtained and the sentence imposed. Their failure to clearly set forth how or in what manner the convictions were declared constitutionally invalid rendered the complaint vulnerable to demurrer for uncertainty. A similar infirmity is to be found in the failure of the complaint to set forth when the alleged causes of action arose and when the setting aside of the previous convictions occurred. These matters are material to plaintiffs' cause of action.[5]
We observe that these objections of uncertainty would also be grounds for general demurrer because they are uncertainties with regard to matters not alleged which are essential to the cause of action (see Dumm v. Pacific Valves, 146 Cal. App.2d 792, 799 [304 P.2d 738]) rather than matters merely creating a doubt as to what the pleader means by the facts alleged. (See Butler v. Sequeira, 100 Cal. App.2d 143, 145-146 [223 P.2d 48]; Brea v. McGlashan, 3 Cal. App.2d 454, 459-460 [39 P.2d 877].)
We do not perceive that because the nature of the proceeding by which plaintiffs have obtained an adjudication with respect to the validity of the subject convictions and the dates when such adjudications occurred should be a matter of public record, these matters are presumptively within the knowledge of defendant so as to preclude a demurrer for uncertainty. Plaintiffs, apparently relying on the belief that they have a meritorious class action, have joined every county and city in *635 this state as a defendant to this action. It would stretch credulity to assert that each of said defendants is presumed to know the court or jurisdiction in which plaintiffs' subject convictions have been declared unconstitutional and void.
As respects the ground of special demurrer that the complaint fails to set forth when the filing of plaintiffs' claim with the State Board of Control was made, we note that the complaint states that such a claim was filed within six months prior to the filing of the amended complaint. The amended complaint was filed on January 22, 1975. The amended complaint also discloses by way of exhibit attached thereto that plaintiffs' claims were denied on November 25, 1974. Accordingly, there is no uncertainty with respect to the filing of the claim. Moreover, the date of the filing of the claim is a matter presumptively within the knowledge of defendant state.
In the instant case plaintiffs were given an opportunity to amend the complaint. They declined to do so. (13) It is the rule that when a plaintiff is given the opportunity to amend his complaint and elects not to do so, strict construction of the complaint is required and it must be presumed that the plaintiff has stated as strong a case as he can. (Mitchell v. National Auto. & Casualty Ins. Co., 38 Cal. App.3d 599, 603 [113 Cal. Rptr. 391]; Straughter v. Safety Savings & Loan Assn., 244 Cal. App.2d 159, 162 [52 Cal. Rptr. 871].)
(14) It is also the rule that where the lower court sustains the defendant's demurrer with leave to amend and the plaintiff declines to do so, electing to stand on his complaint, the judgment of dismissal must be affirmed if the complaint is objectionable on any ground raised by the demurrer. (Hilltop Properties v. State of California, 233 Cal. App.2d 349, 361-362 [43 Cal. Rptr. 605, 37 A.L.R.3d 109]; Sutter v. Gamel, 210 Cal. App.2d 529, 533 [26 Cal. Rptr. 880].) In the instant case, as pointed out above, the complaint was objectionable on one of the grounds of uncertainty raised by the demurrer. Accordingly, the judgment of dismissal must be affirmed.
The judgment is affirmed.
Sims, J., and Elkington, J., concurred.
Appellants' petition for a hearing by the Supreme Court was denied May 26, 1977.
NOTES
[1]  Code of Civil Procedure section 581 provides: "An action may be dismissed in the following cases: ... 3.... when, after a demurrer to the complaint has been sustained with leave to amend, the plaintiff fails to amend it within the time allowed by the court, and either party moves for such dismissal...."
[2]  Penal Code section 1262, in pertinent part, provides: "... If a judgment against the defendant is reversed and the case is dismissed, or if the appellate court directs a final disposition of the action in defendant's favor, and defendant has theretofore paid a fine in the case, such act shall also be deemed an order of the court that the fine, including any penalty or assessment thereon, be returned to defendant."
[3]  A hearing was denied by the Supreme Court.
[4]  We do not imply that a defendant has an unrestricted right to fines and penalties since he may be subject to certain applicable defenses such as the bar of the statute of limitations. In the present case no issue as to any such defenses is presented.
[5]  We note also that plaintiffs do not allege the amounts of the fines and/or penalties assessed for which they seek recovery. However, this element of uncertainty was not specified as a basis for special demurrer.
