@@ -0,0 +1,3458 @@
+package com.vladmihalcea.hibernate.masterclass.laboratory.inheritance;%0A%0Aimport com.vladmihalcea.hibernate.masterclass.laboratory.util.AbstractTest;%0Aimport org.hibernate.Session;%0Aimport org.junit.Test;%0A%0Aimport javax.persistence.*;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0A/**%0A * TreeTest - Tree Test%0A *%0A * @author Vlad Mihalcea%0A */%0Apublic class TreeTest extends AbstractTest %7B%0A%0A    @Override%0A    protected Class%3C?%3E%5B%5D entities() %7B%0A        return new Class%3C?%3E%5B%5D%7B%0A                LocalFolder.class,%0A                RemoteFolder.class,%0A        %7D;%0A    %7D%0A%0A    @Test%0A    public void testTree() %7B%0A        LOGGER.debug(%22testAddWebResource%22);%0A        doInTransaction(new TransactionCallable%3CVoid%3E() %7B%0A            @Override%0A            public Void execute(Session session) %7B%0A                LocalFolder rootLocalFolder = new LocalFolder();%0A                session.persist(rootLocalFolder);%0A                LocalFolder localFolder1 = new LocalFolder();%0A                rootLocalFolder.addChild(localFolder1);%0A                session.persist(localFolder1);%0A                LocalFolder localFolder11 = new LocalFolder();%0A                localFolder1.addChild(localFolder11);%0A                session.persist(localFolder11);%0A%0A                RemoteFolder rootRemoteFolder = new RemoteFolder();%0A                session.persist(rootRemoteFolder);%0A                RemoteFolder remoteFolder1 = new RemoteFolder();%0A                rootRemoteFolder.addChild(remoteFolder1);%0A                session.persist(remoteFolder1);%0A                RemoteFolder remoteFolder11 = new RemoteFolder();%0A                remoteFolder1.addChild(remoteFolder11);%0A                session.persist(remoteFolder11);%0A                return null;%0A            %7D%0A        %7D);%0A    %7D%0A%0A    @MappedSuperclass%0A    public abstract class GenericHierarchicalDictionary %7B%0A%0A        public abstract GenericHierarchicalDictionary getParent();%0A%0A        public abstract Set%3C? extends GenericHierarchicalDictionary%3E getChildren();%0A%0A    %7D%0A%0A    @Entity%0A    @Table(name = %22LocalFolder%22)%0A    public class LocalFolder extends GenericHierarchicalDictionary %7B%0A%0A        @Id%0A        @GeneratedValue(strategy=GenerationType.IDENTITY)%0A        private Long id;%0A%0A        @ManyToOne%0A        private LocalFolder parent;%0A%0A        @OneToMany(mappedBy = %22parent%22)%0A        private Set%3CLocalFolder%3E children = new HashSet%3CLocalFolder%3E();%0A%0A        @Override%0A        public LocalFolder getParent() %7B%0A            return parent;%0A        %7D%0A%0A        @Override%0A        public Set%3CLocalFolder%3E getChildren() %7B%0A            return children;%0A        %7D%0A%0A        public void addChild(LocalFolder localFolder) %7B%0A            localFolder.parent = this;%0A            children.add(localFolder);%0A        %7D%0A    %7D%0A%0A    @Entity%0A    @Table(name = %22RemoteFolder%22)%0A    public class RemoteFolder extends GenericHierarchicalDictionary %7B%0A%0A        @Id%0A        @GeneratedValue(strategy=GenerationType.IDENTITY)%0A        private Long id;%0A%0A        @ManyToOne%0A        private RemoteFolder parent;%0A%0A        @OneToMany(mappedBy = %22parent%22)%0A        private Set%3CRemoteFolder%3E children = new HashSet%3CRemoteFolder%3E();%0A%0A        @Override%0A        public RemoteFolder getParent() %7B%0A            return parent;%0A        %7D%0A%0A        @Override%0A        public Set%3CRemoteFolder%3E getChildren() %7B%0A            return children;%0A        %7D%0A%0A        public void addChild(RemoteFolder localFolder) %7B%0A            localFolder.parent = this;%0A            children.add(localFolder);%0A        %7D%0A    %7D%0A%7D%0A

Add inheritance test