Advertisement
Guest User

Untitled

a guest
Aug 17th, 2020
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. /**
  2. * A component which marks a {@link com.artemis.Entity} as a chunk and stores its most valuable informations.
  3. */
  4. @Entity
  5. @Table(name = "chunk", uniqueConstraints = {@UniqueConstraint(columnNames={"x", "y"})}, indexes = {@Index(columnList = "x,y")})
  6. @Access(value = AccessType.FIELD)
  7. public class Chunk extends HibernateComponent {
  8.  
  9. public int x;
  10. public int y;
  11. public Date createdOn;
  12.  
  13. @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, fetch = FetchType.EAGER)
  14. @Fetch(FetchMode.JOIN)
  15. @BatchSize(size = 100)
  16. public Set<Location> inChunk = new LinkedHashSet<>();
  17.  
  18. @Transient
  19. public Set<ChunkLoader> loadedBy = new LinkedHashSet<>();
  20.  
  21. public Chunk() {}
  22. public Chunk(int x, int y, Date createdOn) {
  23. this.x = x;
  24. this.y = y;
  25. this.createdOn = createdOn;
  26. }
  27. }
  28.  
  29.  
  30. // later on a system checks what "locations" ( from resources, what ever ) belong inside which chunk and inserts the reference into .inChunk... this happens while we create new trees for example
  31. // Meanwhile the updating system runs its query generation and suddenly stores a reference to a location which is not saved yet... it tries to update the chunk and boom... exception
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement