If you are using JPA 1.0 and this entity model, then you will need to persist and flush both Producto and Pedido instances to have their IDs assigned before you can persist the DetPedido instance that will reference them. Once that is done, you will need to manually set the id values in DetPedido's DetPedidoPK instance so that they match the referenced Producto and DetPedido key values. You cannot insert DetPedido without the DetPedidoPK values having been set.
JPA 2.0 supports derived IDs, which allows marking the relationship as either @ID or @MapsId, indicating that the ID values should be pulled from the joincolumn associated to the relationship. In this case, it would become:
@ManyToOne(optional = false)
@MapsId("idProducto")
private Producto producto;
@ManyToOne(optional = false)
@MapsId("idPedido")
private Pedido pedido;
If you wanted, you could do away with the embeddable within DetPedido and just mark the relationships as the @Id, and because it is composite you would use the DetPedidoPK as the PK class.