Page 1 of 1

override JPA entity column definition

Posted: Sat Nov 29, 2014 12:37 am
by karthik.thombarapu
Hi phillip,

Wanted to override JPA entity's column definition of certain attributes due to the hibernate issue when I set the
blPU.hibernate.hbm2ddl.auto=validate
causing the below issues and later did some home work,
https://hibernate.atlassian.net/i#browse/HHH-6935
http://stackoverflow.com/questions/2411 ... t-in-mysql
https://cedar715.wordpress.com/2009/10/ ... rchar2255/

So, if I extend the broadleaf entity and override the required attribute setting the JPA annotation for column with "columndefinition = mediumtext" is one solution which I can think of and wanted to check with you on the same.

Also, I verified the Broadleaf documentation it only specifies the Metadata overrides which are specific for Broadleaf annotations like AdminPresentation having xml and entity extensions. so is there a way to handle this also?
http://www.broadleafcommerce.com/docs/c ... -overrides

Awaiting your response. thanks.

Re: override JPA entity column definition

Posted: Tue Dec 02, 2014 7:55 pm
by phillipuniverse
There might be a way to do this via class transformations where you bytecode weave the new attributes and replace the properties for that class. You would have to replace all of the JPA annotations though you couldn't just do a part of it.

For an example of this, check out the configuration of adding inventory properties to a Sku on https://github.com/BroadleafCommerce/De ... ml#L74-L96. In this case, we are doing bytecode weaving for the properties from QuantityAvailableSkuTemplate into SkuImpl. I think that you can use the same strategy to replace properties and their JPA annotations in framework classes. In your case, you will copy/paste the definition from the framework (including the exact name of the field) and modify the annotations as you see fit.

I am not really sure if that will work but I feel like there is a good shot of this working.

It would be awesome if you could comment on https://github.com/BroadleafCommerce/Br ... issues/189 if you get to a solution here that we could put into the framework.