Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * A component which marks a {@link com.artemis.Entity} as a chunk and stores its most valuable informations.
- */
- @Entity
- @Table(name = "chunk", uniqueConstraints = {@UniqueConstraint(columnNames={"x", "y"})}, indexes = {@Index(columnList = "x,y")})
- @Access(value = AccessType.FIELD)
- public class Chunk extends HibernateComponent {
- public int x;
- public int y;
- public Date createdOn;
- @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, fetch = FetchType.EAGER)
- @Fetch(FetchMode.JOIN)
- @BatchSize(size = 100)
- public Set<Location> inChunk = new LinkedHashSet<>();
- @Transient
- public Set<ChunkLoader> loadedBy = new LinkedHashSet<>();
- public Chunk() {}
- public Chunk(int x, int y, Date createdOn) {
- this.x = x;
- this.y = y;
- this.createdOn = createdOn;
- }
- }
- // 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
- // 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement