Can not add the same GeneratedColumn twice, id:

I am seeing this error when I try to refresh my table again. Caused by: java.lang.IllegalArgumentException: Can not add the same GeneratedColumn twice, id: Here;s the code I have

Exception I am seeing is:
Caused by: java.lang.IllegalArgumentException: Can not add the same GeneratedColumn twice, id:
at com.vaadin.ui.Table.addGeneratedColumn(Table.java:3762)
at gov.noaa.cls.tools.presentation.BuildUserSearchForm.refreshResultsTable(BuildUserSearchForm.java:126)
at gov.noaa.cls.tools.presentation.BuildUserSearchForm.access$0(BuildUserSearchForm.java:109)



public class BuildUserSearchForm extends CustomComponent {

	Table resultsTable;
	Label resultsLabel;
	Form userSearchForm;
	Button searchButton, resetButton;
	HorizontalLayout hl;

	public BuildUserSearchForm() {

		resultsTable = new UserResultsTable();
		resultsLabel = new Label();
		userSearchForm = new Form();
		searchButton = new Button();
		resetButton = new Button();
		hl = new HorizontalLayout();

		final String[] fieldProperties = new String[]
 { "userKey", "firstName", "lastName", "userId" };
		final String[] fieldNames = new String[]
 { "User Key", "First Name", "Last Name", "User ID" };

		// Add a field and bind it to an named item property.
		hl.setSpacing(true);
		userSearchForm.setLayout(hl);
		userSearchForm.addField(fieldProperties[0]
, new TextField(fieldNames[0]
));
		userSearchForm.addField(fieldProperties[1]
, new TextField(fieldNames[1]
));
		userSearchForm.addField(fieldProperties[2]
, new TextField(fieldNames[2]
));
		userSearchForm.addField(fieldProperties[3]
, new TextField(fieldNames[3]
));
		userSearchForm.getField(fieldProperties[3]
).addValidator(new IntegerValidator("User ID must be a number"));

		userSearchForm.setCaption("Search User Registrations");
		userSearchForm.setDescription("Enter search criteria and hit the search button.");
		searchButton.setCaption("Search");
		resetButton.setCaption("Reset");

		userSearchForm.getFooter().addComponent(searchButton);
		userSearchForm.getFooter().addComponent(resetButton);

		// This is listener for the search button of the user search form
		searchButton.addListener(new ClickListener() {
			@Override
			public void buttonClick(ClickEvent event) {
				UserReg userRegExample = new UserReg();
				String userKeyField = userSearchForm.getField(fieldProperties[0]
).getValue().toString();
				String firstNameField = userSearchForm.getField(fieldProperties[1]
).getValue().toString();
				String lastNameField = userSearchForm.getField(fieldProperties[2]
).getValue().toString();
				String userIdField = userSearchForm.getField(fieldProperties[3]
).getValue().toString();

				if (userKeyField.isEmpty() && firstNameField.isEmpty() && lastNameField.isEmpty() && userIdField.isEmpty()) {
					getApplication().getMainWindow().showNotification("Please fill in search criteria", Notification.TYPE_WARNING_MESSAGE);
				} else {
					userRegExample.setUserKey(userKeyField);
					userRegExample.setFirstName(firstNameField);
					userRegExample.setLastName(lastNameField);
					if (!userIdField.isEmpty()) {
						userRegExample.setUserId(Long.parseLong(userIdField));
					}

					refreshResultsTable(userRegExample);
				}

			}
		});

		resetButton.addListener(new ClickListener() {

			@Override
			public void buttonClick(ClickEvent event) {

				userSearchForm.getField("userKey").setValue("");
				userSearchForm.getField("firstName").setValue("");
				userSearchForm.getField("lastName").setValue("");
				userSearchForm.getField("userId").setValue("");

			}
		});

		// return form;
		setCompositionRoot(userSearchForm);

	}

	private void refreshResultsTable(UserReg userRegExample) {

		final Object[] COL_ORDER = new Object[]
 { "", "userId", "userKey", "firstName", "lastName", "subscriber", "archive", "unix", "bulkOrder", "dateLastOn",
				"createDate", "numberOfAccesses", "userEmails" };
		final String[] COL_HEADERS = new String[]
 { "", "USER ID", "USER KEY", "FIRST NAME", "LAST NAME", "SUBS", "ARCHIVE", "UNIX", "BULK", "LAST ACCESSED",
				"CREATE DATE", "# OF ACCESSES", "EMAIL(s)" };

		SpringVaadinApplication spa = (SpringVaadinApplication) getApplication();
		spa.resultsLayout.removeAllComponents();

		final List<UserReg> userRegs = spa.getOrdersCopaManager().findUsers(userRegExample);

		if (userRegs.size() > 0) {
			BeanItemContainer<UserReg> container = new BeanItemContainer<UserReg>(UserReg.class);
			// Add all the elements you got from running the query
			container.addAll(userRegs);

			resultsTable.addGeneratedColumn("", new ColumnGenerator() {                 <<<<<<<<<<<<<<<<< Line thats failing is this according to exception
				@Override
				public Object generateCell(final Table source, final Object itemId, Object columnId) {

					Button viewDetailsButton = new Button("+");
					viewDetailsButton.addListener(new ClickListener() {
						@Override
						public void buttonClick(ClickEvent event) {
							showDetailsAboutUser(itemId);
						}
					});
					return viewDetailsButton;
				}
			});

Well the exception is rather clear … whenever refreshResultTable() gets called, a generated column get added, every time using the same id. That is not allowed and therefore it’s failing.

thankyou. i got this working but removing the code out of the constructor

one can also use this

	returnTable.removeGeneratedColumn("");
            /*
                then do this

             */

	returnTable.addGeneratedColumn("", new ColumnGenerator() {
		@Override
		public Object generateCell(final Table source, final Object itemId, Object columnId) {

			Button viewDetailsButton = new Button("+");
			viewDetailsButton.addListener(new ClickListener() {
				@Override
				public void buttonClick(ClickEvent event) {
					somethingfunction(itemId);
				}
			});
			return viewDetailsButton;
		}
	});