Maxxx873 commented on code in PR #2452:
URL: https://github.com/apache/james-project/pull/2452#discussion_r1802473504


##########
event-sourcing/event-store-jpa/src/main/java/org/apache/james/eventsourcing/eventstore/jpa/model/JPAEvent.java:
##########
@@ -0,0 +1,122 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.eventsourcing.eventstore.jpa.model;
+
+import static 
org.apache.james.eventsourcing.eventstore.jpa.model.JPAEvent.DELETE_AGGREGATE_QUERY;
+import static 
org.apache.james.eventsourcing.eventstore.jpa.model.JPAEvent.JPAEventId;
+import static 
org.apache.james.eventsourcing.eventstore.jpa.model.JPAEvent.SELECT_AGGREGATE_QUERY;
+
+import java.io.Serializable;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.IdClass;
+import jakarta.persistence.Index;
+import jakarta.persistence.NamedQuery;
+import jakarta.persistence.Table;
+
+import org.apache.james.eventsourcing.AggregateId;
+import org.apache.james.eventsourcing.EventId;
+
+import com.google.common.base.Objects;
+
+
+
+/**
+ * JPAEvent class for the James Event Sourcing to be used for JPA persistence.
+ */
+@Entity(name = "JPAEvent")
+@Table(name = JPAEvent.JAMES_EVENTS, indexes = {
+    @Index(name = "AGGREGATE_ID_INDEX", columnList = "AGGREGATE_ID")
+})
+@NamedQuery(name = SELECT_AGGREGATE_QUERY, query = "SELECT e FROM JPAEvent e 
WHERE e.aggregateId=:aggregateId")
+@NamedQuery(name = DELETE_AGGREGATE_QUERY, query = "DELETE FROM JPAEvent e 
WHERE e.aggregateId=:aggregateId")
+@IdClass(JPAEventId.class)
+public class JPAEvent {
+    public static final String SELECT_AGGREGATE_QUERY = 
"selectAggregateEvents";
+    public static final String DELETE_AGGREGATE_QUERY = 
"deleteAggregateEvents";
+
+    public static final String JAMES_EVENTS = "JAMES_EVENTS";
+
+    public static class JPAEventId implements Serializable {
+
+        private static final long serialVersionUID = 1L;
+
+        private String aggregateId;
+
+        private int eventId;
+
+        public JPAEventId() {
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hashCode(aggregateId, eventId);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null || getClass() != obj.getClass()) {
+                return false;
+            }
+            final JPAEventId other = (JPAEventId) obj;
+            return Objects.equal(this.aggregateId, other.aggregateId)
+                && Objects.equal(this.eventId, other.eventId);
+        }

Review Comment:
   > Not sure what you mean here.
   
   Hello, you could use https://jqno.nl/equalsverifier/ for test



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to