-2

Note : I am using PostgreSQL database After the build and run table is not created in database I do same as broadleaf documentation for create new entity:

   1.  **Created new interface** :

package com.mycompany.entity.ordereturn;

 public interface OrderReturn {
        Long getId();
        void setId(Long id);
        String getReason();
        void setReason(String reason);
        String getAddress();
        void setAddress(String address);
    }
  1. Created new OrderReturnImpl class :

    @Entity

    @Table(name = "blc_order_return")

    public class OrderReturnImpl implements OrderReturn{
    
    @Id
    @GeneratedValue(generator= "OrderReturnId")
    @GenericGenerator(
            name="OrderReturnId",
                        strategy="org.broadleafcommerce.common.persistence.IdOverrideTableGenerator",
            parameters = {
                @Parameter(name="segment_value", value="OrderReturnImpl"),
                @Parameter(name="entity_name", value="com.mycompany.entity.ordereturn.OrderReturnImpl")
            }
        )    
    
    @Column(name = "OrderReturn_ID")
    protected Long id;
    
    @Column(name = "Reason")
    protected String reason;
    
    @Column(name = "Address")
    protected String address;
    
    @Override
    public Long getId() {
        // TODO Auto-generated method stub
        return id;
    }
    
    @Override
    public void setId(Long id) {
        // TODO Auto-generated method stub
        this.id = id;
    }
    
    @Override
    public String getReason() {
        // TODO Auto-generated method stub
        return reason;
    }
    
    @Override
    public void setReason(String reason) {
        // TODO Auto-generated method stub
        this.reason = reason;
    }
    
    @Override
    public String getAddress() {
        // TODO Auto-generated method stub
        return address;
    }
    
    @Override
    public void setAddress(String address) {
        // TODO Auto-generated method stub
        this.address = address;
    }
    }
    
    1. Configure in persistence-core.xml file :
     <persistence-unit name="blPU" transaction-type="RESOURCE_LOCAL">
            // Added this line in name = "blPU"
                <class>com.mycompany.controller.account.OrderReturnImpl</class>
                 <exclude-unlisted-classes/>
            </persistence-unit>
    

2 Answers2

0

Although you havent posted your full OrderReturnImpl.java file, you're probably missing the @Entity annotation (along with @Table annotation).

Please annotate your class accordingly.

OK i see a new edit and you now have the annotations. So the error still continues with these annotations?

if you want to create the database tables from the entities, please use <property name="hibernate.hbm2ddl.auto">create</property>

Apostolos
  • 10,033
  • 5
  • 24
  • 39
0

One possible problem is with creating tables if you are running admin/site on standalone server. Try it on embedded tomcat or jetty.

configure:

  • In admin/resource/runtime-properties/development.properties
blPU.hibernate.hbm2ddl.auto=create
blCMSStorage.hibernate.hbm2ddl.auto=create
blSecurePU.hibernate.hbm2ddl.auto=create
  • In core/resource/runtime-properties/common-shared.properties
blPU.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
blSecurePU.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
blCMSStorage.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
blPU.hibernate.hbm2ddl.import_files_sql_extractor=org.broadleafcommerce.common.util.sql.importsql.DemoPostgresSingleLineSqlCommandExtractor
blSecurePU.hibernate.hbm2ddl.import_files_sql_extractor=org.broadleafcommerce.common.util.sql.importsql.DemoPostgresSingleLineSqlCommandExtractor
blCMSStorage.hibernate.hbm2ddl.import_files_sql_extractor=org.broadleafcommerce.common.util.sql.importsql.DemoPostgresSingleLineSqlCommandExtractor
  • database.properties populated with your data

Be sure to have:

  • PostgreSQL driver in [standaloneserver]/lib or as a library if you run on embedded servers

  • Invalidated IDE cache

  • Clean and install maven goals on all project (or on all three modules)

  • postgresql start database in pom's executions and postgresql dependency

<plugin>
     <artifactId>maven-antrun-plugin</artifactId>
     <version>1.8</version>
          <executions>
               <execution>
                    <id>postgres-start</id>
                    <configuration>
                         <target>
                              <echo message="Starting postgres database..."/>
                              <java fork="true" spawn="true" classname="org.postgresql.Driver"
                                      classpathref="maven.plugin.classpath">
                              </java>
                              <echo message="Database started successfully"/>
                         </target>
                     </configuration>
                     <goals>
                         <goal>run</goal>
                     </goals>
                 </execution>
              </executions>
              <dependencies>
                  <dependency>
                      <groupId>org.postgresql</groupId>
                      <artifactId>postgresql</artifactId>
                      <version>9.4.1211</version>
                  </dependency>
              </dependencies>
Zildyan
  • 1,261
  • 9
  • 11