Pergunta

I have less than 5 Product types, and i have been following the manual at:
http://docs.broadleafcommerce.org/current/Extending-Entities-Tutorial.html up until "Single table inheritance", since i only have a fewer variations, i dont want to use Single table inheritance. I have done the following, however after rebuild and restart i dont see any tables created in the database. any ideas?

Books

@Entity
@Table(name="SB_BOOKS")
public class BookImpl extends ProductImpl implements Books {
.....
}

Persistence.xml

<class>com.xproject.core.catalog.domain.BookImpl</class>

context-entity.xml

<bean id="com.xproject.core.catalog.domain.Book" class="com.xproject.core.catalog.domain.BookImpl" scope="prototype"/>

UPDATE: Please note that Table does get created if i override (extend) the BLC ProductImpl bean like this

<bean id="org.broadleafcommerce.core.catalog.domain.ProductImpl" class="com.xproject.core.catalog.domain.BookImpl" scope="prototype"/>
Foi útil?

Solução 2

Fixed it by following phillips hints into the BLC Code, and adding the Inheritance annotation and strategy (JOINED).

@Entity
@Table(name="SB_BOOKS")
@Inheritance(strategy = InheritanceType.JOINED) /* FIX */
public class BookImpl extends ProductImpl implements Books {
.....
}

Outras dicas

What is your blPU.hibernate.hbm2.ddl.auto set to in 'development.properties'? If you want Hibernate to automatically create tables for you then you should have this set to 'create' or 'create-drop'. Also note that by default, the 2 applications (site and admin) have different values for this. The admin is set to 'update' while the site is set to 'create-drop'. If you were to only start up the admin, because the Hibernate DDL is set to 'update', I do not believe that your new table would be created.

I also assume that you have created this domain in the 'core' project which is also recommended.

Source: being a Broadleaf engineer :)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top