Remove dynamic attribute in hybris through backoffice - java

When the dynamic attribute is removed from the items.xmls, hybris reports an error because the attribute handler Spring bean don't exist. This error usually prevents saving models of the Hybris type which owned the attribute. Even after the bean declaration and attribute are removed, hybris still complains about the existance of the reference to a bean.
How to remove DynamicAttributeHandler from the DB through backoffice in Hybris?

The cleanest way to do this is to go to backoffice -> Types -> search for your type -> Properties and then remove the property and save.

You have to remove your custom attribute from the Attributedescriptors table.
Use a direct SQL statement :
DELETE FROM attributedescriptors WHERE (QualifierInternal ='attributename')

Related

where is Session's attributes are saved

I'm trying to add an attribute to session, in a huge pre-realized project (web application project using Java and Tapestry framework), but I don't know where the attribute are saved, so that I can declare a new attribute for Session
in fact , I found out that attributes are added like variable into the session declaration, using just session.setAttribute("Attribute", name)
and then it will be saved, and you can access it using session.getAttribute(name)

GAE Datastore Composite Filter error

What actually is happening when I set the datastore filters like this?
Query("Product").setFilter(filter1).setFilter(filter2);
I found that the result is neither AND or OR.
I also tried to use CompositeFilterOperator.and, but I got DatastoreNeedIndexException, where it should return something that match the AND composite filter.
App engine predefined a simple index on each property of an entity. An app engine can define further custom indexes in an index configuration file named datastore-indexes.xml, which is generated in your application's /war/WEB-INF/appengine-generated directory.
You can look at this blog:
http://rlabs.wordpress.com/2009/04/01/fixing-appengine-error-no-matching-index-found-this-query-needs-this-index/

'Order' entity bean

My database has a table name Order. When I create a new CMP Entity bean, NetBeans 6.9.1 automatically generated a bean with 3 classes name:
Order1.java
Order1Local.java
Order1LocalHome.java
I tried to rename those 3 classes to Order without the 1. I've already edit the ejb-jar.xml file. However, I got this error when deploying the project:
JDO7704: This error (In DatabaseGenerator, failed to get 'relClassName' for 'order') should not occur
I also tried the name OrderBean but it only works with Order1. What should I do to rename my entity bean to Order.
Order is a reserved word in some dbms (used in order by expressions). Maybe that is the reason why Netbeans adds the 1. You should name your table different.
Just found this useful tool: SQL Reserved Words Checker. It says that Order is not reserved in ISO/ANSI,SQL99 but in dbms like DB2 or Oracle.

Creating custom user attributes in Active Directory using JNDI

I am attempting to create a custom attribute that can be assigned to an existing Active Directory user in my domain. I am not fully aware of how to achieve this. It is my understanding that once the attribute has been created, I can assign it to the user via:
mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE, new BasicAttribute("attributeName", "attributeValue"))
ctx.modifyAttributes(userDN, mods)
Any information is appreciated.
Not sure what you want to do.
But Active-Directory is a Directory, so it use a SCHEMA to define which attributes can be used in an object. This means that you can modify (add, delete, replace) the value of an attribut that exists (in the SCHEMA) for a given class, but can'nt add a custom attribut to a class without modifying the SCHEMA.

Submitting / binding partial objects with spring mvc

The Spring MVC binding mechanism is powerful, but I'm now confronted with a trivial issue that I wonder how to resolve:
User JPA entity, that is used for the binding and validation as well (i.e. throughout all layers)
"Edit profile" page, that is not supposed to change the password or some other entity properties
Two ways that I can think of:
Using the same object
use #InitBinder to configure a list of disallowed properties
obtain the target user (by id)
then use a reflection utility (BeanUtils) to copy the submitted object to the target object, but ignore null values - i.e. fields that are not submitted
Introduce a new object that has the needed subset of fields, and use BeanUtils.copyProperties(..) to merge it to the entity.
Alternatives?
I've found that as soon as your web model starts to diverge from your business layer in function, it's best to use a view layer object (a model object) to collect, or display the data
the entity:
public class com.myapp.domain.UserEntity {
}
the model object:
public class com.myapp.somesite.web.SomeSiteUserModel {
public static SomeSiteUserModel from(UserEntity userEntity) {
... initialize model ...
}
public UserEntity getModelObject() {
... get entity back ...
}
}
now all view based operations can hand off processing to the internal model object if that makes sense, otherwise it can customize them itself. Of course the problem with this is you have to re-write all the getters and setters you want for the entity (an issue that I've had to deal with, that is annoying) unfortunately that is a bit of a Java language issue
I just checked up with two of the last Spring projects I have worked on and in both places the following approach is taken:
In the JSP page for the form the change password field has a name that does not match the name of the password field in the User bean, so that it doesn't get mapped to the bean. Then in the onSubmit method there is a separate check whether a new password has been submitted, and if it has been, the change is reflected explicitly.
Поздрави,
Vassil
You can read the object from the database first and bind then the request. You can find an example at FuWeSta-Sample.
It uses a helper-bean which must be initialized by Spring.

Categories