Describe a bean once -- get the beans.xml declaration and a preview of the Java class ybeangenerator would produce from it.
🔒 Your code never leaves your browser — everything is generated locally from templates, no AI, no server round-trip.
trainingcore/resources/trainingcore-beans.xml<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.hybris.de/xsd/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="beans.xsd">
<bean class="MyData" abstract="false">
</bean>
</beans>
A DTO ("Data") class in SAP Commerce (Hybris) -- things like ProductData, CartData, or a custom LoyaltyAccountData -- is never written by hand as a Java class. Instead you declare it as a <bean> in an extension's -beans.xml, and the platform build's bean-code-generator (ybeangenerator) generates the real .java class (fields, getters/setters, Serializable) into a gensrc folder at build time.
beans.xml also supports its own nested <enum> declarations, bean inheritance via extends (e.g. extending the OOTB ProductData to add a field), and generic property types like java.util.List<java.lang.String> -- all translated into equivalent Java by the generator.
Use a DTO/bean whenever you need a plain data-carrier to move data between layers -- out of a Populator, into a Converter, across a REST controller (OCC), or as the return type of a facade method -- rather than exposing a persistence model (a *Model class) directly to a view or an API response.
Reach for extends on an existing OOTB bean (like ProductData) when you only need to add one or two extra fields to data the platform already returns, instead of inventing a parallel bean and a parallel converter.
beans.xml is the single source of truth the platform build reads to generate the class (and keep it consistent with extends/property changes across extensions). A hand-written class would be overwritten on the next build anyway, and you'd lose the declarative inheritance beans.xml gives you for free.
Set "extends" on your bean to the OOTB bean's simple name (e.g. ProductData) -- the generated class will extend it in Java, inheriting all of its properties, and you only declare the new fields your bean adds.
Yes -- write the fully-qualified generic form, e.g. java.util.List<java.lang.String> or java.util.Map<java.lang.String, java.lang.Integer>. beans.xml has no import mechanism, so every segment of a generic type must be fully qualified or be a bean/enum declared elsewhere in the system.
A beans.xml <enum> block declares a plain Java enum (not to be confused with an items.xml <enumtype>, which is a persisted platform type). It's generated the same way as a bean -- a real top-level .java enum file -- and can be referenced as a property type on any bean in the same or a dependent extension.
During the platform build (ant build/ant yall, or an equivalent IDE build step) via ybeangenerator, which reads every -beans.xml on the classpath and writes the generated classes into each extension's gensrc folder. The preview tab here mimics that output for a quick sanity check -- it is not what the build produces verbatim and is never meant to be committed.