| /* |
| * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. |
| * |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0, |
| * or the Eclipse Distribution License v. 1.0 which is available at |
| * http://www.eclipse.org/org/documents/edl-v10.php. |
| * |
| * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause |
| */ |
| |
| // Contributors: |
| // Oracle - initial API and implementation from Oracle TopLink |
| package org.eclipse.persistence.testing.models.jpa.xml.inheritance.listeners; |
| |
| import jakarta.persistence.PostLoad; |
| import jakarta.persistence.PostPersist; |
| |
| public class DefaultListener { |
| // Not going to test all the callbacks from the default listener |
| // since the listener gets added to 90+ classes and when testing that |
| // is a lot of notifications which slows things down. Just |
| // going to test a couple of the callbacks which should be |
| // good enough. |
| |
| public static int PRE_PERSIST_COUNT = 0; |
| public static int POST_PERSIST_COUNT = 0; |
| public static int POST_LOAD_COUNT = 0; |
| |
| public DefaultListener() { |
| super(); |
| } |
| |
| @PostLoad |
| // Defined in XML, annotations processor should ignore this one. |
| // If @PostLoad was defined on another method than it should throw |
| // and exception cause we have multiple methods for the same call |
| // back defined. Exception throwing tested manually. |
| public void postLoad(Object obj) { |
| POST_LOAD_COUNT++; |
| } |
| |
| // @PrePersist |
| // Defined in XML, test that we pick it up. |
| public void prePersist(Object obj) { |
| PRE_PERSIST_COUNT++; |
| } |
| |
| @PostPersist |
| public void postPersist(Object obj) { |
| POST_PERSIST_COUNT++; |
| } |
| } |